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

# Generate chat completion

> Generate a chat completion from a prompt using one model in your project.
Your prompt messages can include several roles.
This endpoints supports streaming



## OpenAPI

````yaml POST /api/v1/chat/completions
openapi: 3.1.0
info:
  title: concorde
  description: ''
  license:
    name: UNLICENSED
    identifier: UNLICENSED
  version: 0.1.0
servers: []
security: []
tags:
  - name: Interactions
    description: Load interactions in the db
  - name: Chunked Upload
    description: Upload large files in chunks
  - name: Recipes
    description: Recipe operations
paths:
  /api/v1/chat/completions:
    post:
      tags:
        - Completions
      summary: Generate chat completion
      description: >-
        Generate a chat completion from a prompt using one model in your
        project.

        Your prompt messages can include several roles.

        This endpoints supports streaming
      operationId: Chat
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatInput'
        required: true
      responses:
        '200':
          description: a stream will be returned if `streaming = true` in the request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatResponse'
            text/event-stream:
              schema:
                $ref: '#/components/schemas/ChatResponseChunk'
components:
  schemas:
    ChatInput:
      allOf:
        - $ref: '#/components/schemas/GenerateParameters'
        - type: object
          required:
            - messages
            - model
          properties:
            messages:
              type: array
              items:
                $ref: '#/components/schemas/ChatMessageInput'
            model:
              type: string
              description: >-
                can be of the form `{project}/{model}` or `{project}`. In the
                latter it will use the default model
            stream:
              type: boolean
            stream_options:
              oneOf:
                - type: 'null'
                - $ref: '#/components/schemas/StreamOptions'
            session_id:
              type:
                - string
                - 'null'
              format: uuid
            user:
              type:
                - string
                - 'null'
              format: uuid
            ab_campaign:
              oneOf:
                - type: 'null'
                - $ref: '#/components/schemas/IdOrKey'
            'n':
              type: integer
              format: int32
              minimum: 0
            labels:
              oneOf:
                - type: 'null'
                - $ref: '#/components/schemas/DictString'
            metadata:
              oneOf:
                - type: 'null'
                - $ref: '#/components/schemas/DictString'
                  description: alias for labels
            system_prompt_args:
              type:
                - object
                - 'null'
              description: Will be used to render system prompt template
              additionalProperties: {}
              propertyNames:
                type: string
            tags:
              type:
                - array
                - 'null'
              items:
                type: string
            use_tools:
              type: boolean
            tools:
              type:
                - array
                - 'null'
              items:
                $ref: '#/components/schemas/ToolOverride'
              description: >-
                Override tool configuration for this request - enables/disables
                specific tools
            store:
              type:
                - boolean
                - 'null'
    ChatResponse:
      type: object
      required:
        - id
        - created
        - choices
        - session_id
        - usage
      properties:
        id:
          type: string
        created:
          $ref: '#/components/schemas/Timestampsec'
        choices:
          type: array
          items:
            $ref: '#/components/schemas/ChatChoice'
        session_id:
          type: string
          format: uuid
        usage:
          $ref: '#/components/schemas/Usage'
    ChatResponseChunk:
      type: object
      required:
        - id
        - choices
        - created
        - session_id
      properties:
        id:
          type: string
        choices:
          type: array
          items:
            $ref: '#/components/schemas/Delta'
        created:
          $ref: '#/components/schemas/Timestampsec'
        session_id:
          type: string
          format: uuid
        usage:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/Usage'
    GenerateParameters:
      type: object
      properties:
        stop:
          type:
            - array
            - 'null'
          items:
            type: string
        max_tokens:
          type:
            - integer
            - 'null'
          format: int32
          minimum: 0
        temperature:
          type:
            - number
            - 'null'
          format: float
        top_p:
          type:
            - number
            - 'null'
          format: float
        max_ttft_ms:
          type:
            - integer
            - 'null'
          format: int64
          minimum: 0
    ChatMessageInput:
      type: object
      required:
        - content
        - role
      properties:
        content:
          $ref: '#/components/schemas/MessagePackage'
        role:
          type: string
        name:
          type:
            - string
            - 'null'
        completion_id:
          type:
            - string
            - 'null'
          format: uuid
        metadata: {}
    StreamOptions:
      type: object
      properties:
        include_usage:
          type: boolean
    IdOrKey:
      type: string
      description: id or key of the entity
      examples:
        - 76d1fab3-214c-47ef-bb04-16270639bf89
    DictString:
      type: object
      description: dictionnary with key and values as string
      additionalProperties:
        type: string
      examples:
        - key: value
    ToolOverride:
      type: object
      required:
        - id
        - enabled
      properties:
        id:
          type: string
        enabled:
          type: boolean
    Timestampsec:
      type: number
      description: Unix Timestamp in seconds
      examples:
        - '1720712536'
    ChatChoice:
      type: object
      required:
        - index
        - message
        - completion_id
        - model
      properties:
        index:
          type: integer
          format: int32
          minimum: 0
        message:
          $ref: '#/components/schemas/ChatChoiceMessage'
        finish_reason:
          type:
            - string
            - 'null'
        completion_id:
          type: string
        model:
          type: string
    Usage:
      type: object
      required:
        - completion_tokens
        - prompt_tokens
        - total_tokens
      properties:
        completion_tokens:
          type: integer
          format: int32
          minimum: 0
        prompt_tokens:
          type: integer
          format: int32
          minimum: 0
        total_tokens:
          type: integer
          format: int32
          minimum: 0
    Delta:
      type: object
      required:
        - delta
        - index
        - completion_id
      properties:
        delta:
          $ref: '#/components/schemas/ChatChoiceMessage'
        index:
          type: integer
          format: int32
          minimum: 0
        completion_id:
          type: string
        finish_reason:
          type:
            - string
            - 'null'
    MessagePackage:
      oneOf:
        - type: string
        - type: array
          items:
            $ref: '#/components/schemas/MessageContentPart'
    ChatChoiceMessage:
      type: object
      required:
        - id
        - role
        - content
      properties:
        id:
          type: string
        role:
          type: string
        content:
          type: string
    MessageContentPart:
      oneOf:
        - type: object
          required:
            - text
            - type
          properties:
            text:
              type: string
            type:
              type: string
              enum:
                - text
        - type: object
          required:
            - image_url
            - type
          properties:
            image_url:
              type: string
            type:
              type: string
              enum:
                - image_url

````