> ## Documentation Index
> Fetch the complete documentation index at: https://www.cometchat.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> Creates a new BYO Agent that delegates conversations to an external AI Agent. Use this endpoint to register a BYO (Bring Your Own) agent powered by frameworks like Mastra, CrewAI, or LangGraph.  **Val

# Create BYO Agent

For the complete error reference, see [Error Guide](/rest-api/byo-ai-agents-apis/error-codes).


## OpenAPI

````yaml post /ai-agents/agents
openapi: 3.0.0
info:
  title: AI Agents APIs
  description: API reference for CometChat AI Agents service
  version: '1.0'
servers:
  - url: https://{appId}.api-{region}.cometchat.io/v3
    variables:
      appId:
        default: appId
        description: (Required) App ID
      region:
        enum:
          - us
          - eu
          - in
        default: us
        description: Select Region
security: []
tags:
  - name: ai-agent
    description: ''
paths:
  /ai-agents/agents:
    post:
      tags:
        - Agents
      summary: Create BYO Agent
      description: >-
        Creates a new BYO Agent that delegates conversations to an external AI
        Agent. Use this endpoint to register a BYO (Bring Your Own) agent
        powered by frameworks like Mastra, CrewAI, or LangGraph.


        **Validation:** All referenced tools and actions are validated before
        the agent is created.
      operationId: AgentsController_createAgent
      parameters:
        - name: chatApiVersion
          required: false
          in: header
          description: Chat API version. Defaults to `v3.0`.
          schema:
            type: string
            default: v3.0
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateAgentDTO'
      responses:
        '201':
          description: Agent created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  agent:
                    type: object
                    properties:
                      uid:
                        type: string
                        description: Unique identifier of the agent
                      appId:
                        type: string
                        description: Application ID
                      name:
                        type: string
                        description: Name of the agent
                      icon:
                        type: string
                        description: URL to the agent's avatar
                      isActive:
                        type: boolean
                        description: Whether the agent is active
                      integrateWith:
                        type: string
                        description: Integration platform identifier
                      integrationType:
                        type: string
                        description: Type of connection
                      tools:
                        type: array
                        items:
                          type: string
                        description: List of connected tools
                      actions:
                        type: array
                        items:
                          type: string
                        description: List of connected actions
                      integrationMeta:
                        type: object
                        description: Integration-specific configuration
                        properties:
                          baseUrl:
                            type: string
                          agentId:
                            type: string
                      metaData:
                        type: object
                        description: Agent metadata
                        properties:
                          greetingMessage:
                            type: string
                          introductoryMessage:
                            type: string
                          suggestedMessages:
                            type: array
                            items:
                              type: string
                      _id:
                        type: string
                        description: Internal document ID
                      createdAt:
                        type: integer
                        format: date-time
                        description: Creation timestamp
                      updatedAt:
                        type: integer
                        format: date-time
                        description: Last update timestamp
              example:
                agent:
                  uid: 550e8400-e29b-41d4-a716-446655440000
                  appId: my-app-id
                  name: My Agent
                  icon: https://example.com/icon.png
                  isActive: true
                  integrateWith: openai
                  integrationType: agent
                  tools:
                    - tool1
                  actions:
                    - action1
                  instruction: You are a helpful assistant
                  integrationMeta: {}
                  metaData: {}
                  deletedAt: null
                  createdAt: '2025-12-01T00:00:00.000Z'
                  updatedAt: '2025-12-01T00:00:00.000Z'
      security:
        - apiKey: []
components:
  schemas:
    CreateAgentDTO:
      discriminator:
        propertyName: integrateWith
        mapping:
          mastra:
            $ref: '#/components/schemas/CreateMastraAgentDTO'
          mastra-legacy:
            $ref: '#/components/schemas/CreateMastraLegacyAgentDTO'
          langgraph:
            $ref: '#/components/schemas/CreateLangGraphAgentDTO'
          crewai:
            $ref: '#/components/schemas/CreateCrewAIAgentDTO'
          vercelV5:
            $ref: '#/components/schemas/CreateVercelV5AgentDTO'
          ag2:
            $ref: '#/components/schemas/CreateAG2AgentDTO'
          rasa:
            $ref: '#/components/schemas/CreateRasaAgentDTO'
          agno:
            $ref: '#/components/schemas/CreateAgnoAgentDTO'
          ag-ui:
            $ref: '#/components/schemas/CreateAGUIAgentDTO'
      oneOf:
        - $ref: '#/components/schemas/CreateMastraAgentDTO'
        - $ref: '#/components/schemas/CreateMastraLegacyAgentDTO'
        - $ref: '#/components/schemas/CreateLangGraphAgentDTO'
        - $ref: '#/components/schemas/CreateCrewAIAgentDTO'
        - $ref: '#/components/schemas/CreateVercelV5AgentDTO'
        - $ref: '#/components/schemas/CreateAG2AgentDTO'
        - $ref: '#/components/schemas/CreateRasaAgentDTO'
        - $ref: '#/components/schemas/CreateAgnoAgentDTO'
        - $ref: '#/components/schemas/CreateAGUIAgentDTO'
    CreateMastraAgentDTO:
      title: Mastra
      type: object
      required:
        - name
        - integrateWith
        - integrationType
        - icon
      properties:
        name:
          type: string
          description: Name of the agent
          example: My Mastra Agent
        icon:
          type: string
          format: url
          description: URL to the icon/avatar of the agent
        isActive:
          type: boolean
          default: true
          description: Whether the agent is active
        integrateWith:
          type: string
          enum:
            - mastra
          description: Integration platform identifier
        integrationType:
          type: string
          enum:
            - agent
          description: Type of connection
        integrationMeta:
          type: object
          required:
            - baseUrl
          description: Mastra-specific configuration
          properties:
            baseUrl:
              type: string
              description: The web address where your Mastra agent is hosted
              example: https://my-mastra-app.example.com
            agentId:
              type: string
              description: Mastra Agent ID
              example: weatherAgent
        tools:
          type: array
          items:
            type: string
          description: List of tool names (must exist in the app's tools)
        actions:
          type: array
          items:
            type: string
          description: List of action names (must exist in the app's actions)
        metaData:
          type: object
          description: Metadata for the agent
          properties:
            greetingMessage:
              type: string
              description: Greeting message shown when a conversation starts
            introductoryMessage:
              type: string
              description: Introductory message for the agent
            suggestedMessages:
              type: array
              items:
                type: string
              description: Quick prompts users can click to start a conversation
    CreateMastraLegacyAgentDTO:
      title: Mastra (Legacy)
      type: object
      required:
        - name
        - integrateWith
        - integrationType
        - icon
      properties:
        name:
          type: string
          description: Name of the agent
          example: My Legacy Mastra Agent
        icon:
          type: string
          format: url
          description: URL to the icon/avatar of the agent
        isActive:
          type: boolean
          default: true
          description: Whether the agent is active
        integrateWith:
          type: string
          enum:
            - mastra-legacy
          description: Integration platform identifier
        integrationType:
          type: string
          enum:
            - agent
          description: Type of connection
        integrationMeta:
          type: object
          required:
            - baseUrl
          description: Mastra (Legacy) configuration
          properties:
            baseUrl:
              type: string
              description: The web address where your Mastra agent is hosted
              example: https://my-mastra-legacy.example.com
            agentId:
              type: string
              description: Mastra Agent ID
              example: weatherAgent
        tools:
          type: array
          items:
            type: string
          description: List of tool names (must exist in the app's tools)
        actions:
          type: array
          items:
            type: string
          description: List of action names (must exist in the app's actions)
        metaData:
          type: object
          description: Metadata for the agent
          properties:
            greetingMessage:
              type: string
              description: Greeting message shown when a conversation starts
            introductoryMessage:
              type: string
              description: Introductory message for the agent
            suggestedMessages:
              type: array
              items:
                type: string
              description: Quick prompts users can click to start a conversation
    CreateLangGraphAgentDTO:
      title: LangGraph
      type: object
      required:
        - name
        - integrateWith
        - integrationType
        - icon
      properties:
        name:
          type: string
          description: Name of the agent
          example: My LangGraph Agent
        icon:
          type: string
          format: url
          description: URL to the icon/avatar of the agent
        isActive:
          type: boolean
          default: true
          description: Whether the agent is active
        integrateWith:
          type: string
          enum:
            - langgraph
          description: Integration platform identifier
        integrationType:
          type: string
          enum:
            - agent
          description: Type of connection
        integrationMeta:
          type: object
          required:
            - baseUrl
          description: LangGraph-specific configuration
          properties:
            baseUrl:
              type: string
              description: The web address where your agent is hosted
              example: https://my-langgraph-app.example.com
            headers:
              type: object
              description: Custom headers as JSON object (e.g., authorization tokens)
              example:
                authorization: Basic your_basic_auth
        tools:
          type: array
          items:
            type: string
          description: List of tool names (must exist in the app's tools)
        actions:
          type: array
          items:
            type: string
          description: List of action names (must exist in the app's actions)
        metaData:
          type: object
          description: Metadata for the agent
          properties:
            greetingMessage:
              type: string
              description: Greeting message shown when a conversation starts
            introductoryMessage:
              type: string
              description: Introductory message for the agent
            suggestedMessages:
              type: array
              items:
                type: string
              description: Quick prompts users can click to start a conversation
    CreateCrewAIAgentDTO:
      title: CrewAI
      type: object
      required:
        - name
        - integrateWith
        - integrationType
        - icon
      properties:
        name:
          type: string
          description: Name of the agent
          example: My CrewAI Agent
        icon:
          type: string
          format: url
          description: URL to the icon/avatar of the agent
        isActive:
          type: boolean
          default: true
          description: Whether the agent is active
        integrateWith:
          type: string
          enum:
            - crewai
          description: Integration platform identifier
        integrationType:
          type: string
          enum:
            - agent
          description: Type of connection
        integrationMeta:
          type: object
          required:
            - baseUrl
          description: CrewAI compatible agent configuration
          properties:
            baseUrl:
              type: string
              description: The web address where your CrewAI agent is hosted
              example: https://my-crewai-app.example.com
            headers:
              type: object
              description: Custom headers as JSON object (e.g., authorization tokens)
              example:
                authorization: Basic your_basic_auth
        tools:
          type: array
          items:
            type: string
          description: List of tool names (must exist in the app's tools)
        actions:
          type: array
          items:
            type: string
          description: List of action names (must exist in the app's actions)
        metaData:
          type: object
          description: Metadata for the agent
          properties:
            greetingMessage:
              type: string
              description: Greeting message shown when a conversation starts
            introductoryMessage:
              type: string
              description: Introductory message for the agent
            suggestedMessages:
              type: array
              items:
                type: string
              description: Quick prompts users can click to start a conversation
    CreateVercelV5AgentDTO:
      title: Vercel AI V5
      type: object
      required:
        - name
        - integrateWith
        - integrationType
        - icon
      properties:
        name:
          type: string
          description: Name of the agent
          example: My Vercel Agent
        icon:
          type: string
          format: url
          description: URL to the icon/avatar of the agent
        isActive:
          type: boolean
          default: true
          description: Whether the agent is active
        integrateWith:
          type: string
          enum:
            - vercelV5
          description: Integration platform identifier
        integrationType:
          type: string
          enum:
            - agent
          description: Type of connection
        integrationMeta:
          type: object
          required:
            - baseUrl
          description: Vercel AI V5 configuration
          properties:
            baseUrl:
              type: string
              description: The web address where your Vercel AI agent is hosted
              example: https://my-vercel-app.vercel.app/api/chat
            headers:
              type: object
              description: Custom headers as JSON object (e.g., authorization tokens)
              example:
                authorization: Bearer token123
        tools:
          type: array
          items:
            type: string
          description: List of tool names (must exist in the app's tools)
        actions:
          type: array
          items:
            type: string
          description: List of action names (must exist in the app's actions)
        metaData:
          type: object
          description: Metadata for the agent
          properties:
            greetingMessage:
              type: string
              description: Greeting message shown when a conversation starts
            introductoryMessage:
              type: string
              description: Introductory message for the agent
            suggestedMessages:
              type: array
              items:
                type: string
              description: Quick prompts users can click to start a conversation
    CreateAG2AgentDTO:
      title: AG2
      type: object
      required:
        - name
        - integrateWith
        - integrationType
        - icon
      properties:
        name:
          type: string
          description: Name of the agent
          example: My AG2 Agent
        icon:
          type: string
          format: url
          description: URL to the icon/avatar of the agent
        isActive:
          type: boolean
          default: true
          description: Whether the agent is active
        integrateWith:
          type: string
          enum:
            - ag2
          description: Integration platform identifier
        integrationType:
          type: string
          enum:
            - agent
          description: Type of connection
        integrationMeta:
          type: object
          required:
            - baseUrl
          description: AG2-specific configuration
          properties:
            baseUrl:
              type: string
              description: The web address where your AG2 agent is hosted
              example: https://my-ag2-app.example.com
            defaultUserId:
              type: string
              description: Default User ID
              example: user_123
            headers:
              type: string
              description: >-
                Headers as key:value pairs, each on a new line. Should be valid
                JSON
              example: '{"authorization": "Bearer token123"}'
        tools:
          type: array
          items:
            type: string
          description: List of tool names (must exist in the app's tools)
        actions:
          type: array
          items:
            type: string
          description: List of action names (must exist in the app's actions)
        metaData:
          type: object
          description: Metadata for the agent
          properties:
            greetingMessage:
              type: string
              description: Greeting message shown when a conversation starts
            introductoryMessage:
              type: string
              description: Introductory message for the agent
            suggestedMessages:
              type: array
              items:
                type: string
              description: Quick prompts users can click to start a conversation
    CreateRasaAgentDTO:
      title: Rasa
      type: object
      required:
        - name
        - integrateWith
        - integrationType
        - icon
      properties:
        name:
          type: string
          description: Name of the agent
          example: My Rasa Agent
        icon:
          type: string
          format: url
          description: URL to the icon/avatar of the agent
        isActive:
          type: boolean
          default: true
          description: Whether the agent is active
        integrateWith:
          type: string
          enum:
            - rasa
          description: Integration platform identifier
        integrationType:
          type: string
          enum:
            - agent
          description: Type of connection
        integrationMeta:
          type: object
          required:
            - baseUrl
          description: Rasa-specific configuration
          properties:
            baseUrl:
              type: string
              description: The web address where your Rasa agent is hosted
              example: https://my-rasa-app.example.com
            headers:
              type: string
              description: Headers as key:value pairs, each on a new line
        tools:
          type: array
          items:
            type: string
          description: List of tool names (must exist in the app's tools)
        actions:
          type: array
          items:
            type: string
          description: List of action names (must exist in the app's actions)
        metaData:
          type: object
          description: Metadata for the agent
          properties:
            greetingMessage:
              type: string
              description: Greeting message shown when a conversation starts
            introductoryMessage:
              type: string
              description: Introductory message for the agent
            suggestedMessages:
              type: array
              items:
                type: string
              description: Quick prompts users can click to start a conversation
    CreateAgnoAgentDTO:
      title: Agno
      type: object
      required:
        - name
        - integrateWith
        - integrationType
        - icon
      properties:
        name:
          type: string
          description: Name of the agent
          example: My Agno Agent
        icon:
          type: string
          format: url
          description: URL to the icon/avatar of the agent
        isActive:
          type: boolean
          default: true
          description: Whether the agent is active
        integrateWith:
          type: string
          enum:
            - agno
          description: Integration platform identifier
        integrationType:
          type: string
          enum:
            - agent
          description: Type of connection
        integrationMeta:
          type: object
          required:
            - baseUrl
          description: Agno-specific configuration
          properties:
            baseUrl:
              type: string
              description: The web address where your Agno agent is hosted
              example: https://my-agno-app.example.com
            agentId:
              type: string
              description: Agno Agent ID
              example: my-agent-id
            headers:
              type: string
              description: Headers as key:value pairs, each on a new line
        tools:
          type: array
          items:
            type: string
          description: List of tool names (must exist in the app's tools)
        actions:
          type: array
          items:
            type: string
          description: List of action names (must exist in the app's actions)
        metaData:
          type: object
          description: Metadata for the agent
          properties:
            greetingMessage:
              type: string
              description: Greeting message shown when a conversation starts
            introductoryMessage:
              type: string
              description: Introductory message for the agent
            suggestedMessages:
              type: array
              items:
                type: string
              description: Quick prompts users can click to start a conversation
    CreateAGUIAgentDTO:
      title: AG-UI
      type: object
      required:
        - name
        - integrateWith
        - integrationType
        - icon
      properties:
        name:
          type: string
          description: Name of the agent
          example: My AG-UI Agent
        icon:
          type: string
          format: url
          description: URL to the icon/avatar of the agent
        isActive:
          type: boolean
          default: true
          description: Whether the agent is active
        integrateWith:
          type: string
          enum:
            - ag-ui
          description: Integration platform identifier
        integrationType:
          type: string
          enum:
            - agent
          description: Type of connection
        integrationMeta:
          type: object
          required:
            - baseUrl
          description: AG-UI compatible agent configuration
          properties:
            baseUrl:
              type: string
              description: The web address where your AG-UI agent is hosted
              example: https://my-agui-app.example.com
            headers:
              type: object
              description: Custom headers as JSON object (e.g., authorization tokens)
              example:
                authorization: Basic your_basic_auth
        tools:
          type: array
          items:
            type: string
          description: List of tool names (must exist in the app's tools)
        actions:
          type: array
          items:
            type: string
          description: List of action names (must exist in the app's actions)
        metaData:
          type: object
          description: Metadata for the agent
          properties:
            greetingMessage:
              type: string
              description: Greeting message shown when a conversation starts
            introductoryMessage:
              type: string
              description: Introductory message for the agent
            suggestedMessages:
              type: array
              items:
                type: string
              description: Quick prompts users can click to start a conversation
  securitySchemes:
    apiKey:
      type: apiKey
      description: API Key (i.e. Rest API Key from the Dashboard).
      name: apikey
      in: header

````