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

# Chat Completions

> Creates a model response for the given chat conversation.



## OpenAPI

````yaml https://dev-platform.algo-tech.ai/api/openapi post /v1/chat/completions
openapi: 3.1.0
info:
  title: Algo API Documentation
  description: >-
    # Introduction

    Algo AI REST API enables you to interact with various Language, Image and
    Embedding Models using the API Key.


    # Authentication

    All requests made to the Algo AI via REST API must include an Authorization
    header.


    Header should specify a valid Bearer Token with API key and must be encoded
    as JSON with the “Content-Type: application/json” header.


    This ensures that your requests are properly authenticated and formatted for
    interaction with the Algo AI.


    A Sample header to be included in the REST API request should look like
    below:

    ```

    authorization: Bearer <API_KEY>

    ```
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.algo-tech.ai
security:
  - bearerAuth: []
paths:
  /v1/chat/completions:
    post:
      summary: Chat Completions
      description: Creates a model response for the given chat conversation.
      parameters:
        - required: true
          name: Authorization
          description: >-
            Bearer authentication header of the form Bearer <API_KEY>, where
            <API_KEY> is your auth token.
          in: header
          schema:
            type: string
            default: Bearer <API_KEY>
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateChatCompletions'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatCompletions'
        '400':
          description: Invalid Request Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessage'
        '402':
          description: Payment Required
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessage'
        '429':
          description: Rate Limit Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessage'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessage'
components:
  schemas:
    CreateChatCompletions:
      type: object
      properties:
        model:
          required: true
          type: string
          description: The name of the model to use.
          example: deepseek-ai/DeepSeek-R1
        messages:
          required: true
          description: A list of messages comprising the conversation so far.
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/ChatCompletionRequestMessage'
        temperature:
          type: number
          minimum: 0
          maximum: 2
          default: 1
          example: 1
          description: >
            What sampling temperature to use, between 0 and 2. Higher values
            like 0.8 will make the output more random, while lower values like
            0.2 will make it more focused and deterministic.


            We generally recommend altering this or `top_p` but not both.
        max_tokens:
          description: >
            The maximum number of tokens to generate in the completion.


            If the token count of your prompt (previous messages) plus
            `max_tokens` exceed the model's context length, the behavior is
            depends on `context_length_exceeded_behavior`. By default,
            `max_tokens` will be lowered to fit in the context window instead of
            returning an error.
          default: 2000
          type: integer
        stream:
          type: boolean
          description: >-
            Whether to stream back partial progress. If set, tokens will be sent
            as data-only server-sent events
          example: true
    ChatCompletions:
      type: object
      properties:
        id:
          type: string
          description: A unique identifier of the response.
        object:
          type: string
          description: The object type, which is always "chat.completion".
        created:
          type: integer
          description: The Unix time in seconds when the response was generated.
        model:
          type: string
          description: The model used for the chat completion.
        choices:
          type: array
          description: The list of chat completion choices.
          items:
            type: object
            properties:
              index:
                type: integer
                description: The index of the chat completion choice.
              message: 529620cf-ff7f-4713-94ba-518afc156af5
              finish_reason:
                type: string
                description: >
                  The reason the model stopped generating tokens. This will be
                  "stop" if

                  the model hit a natural stop point or a provided stop
                  sequence, or

                  "length" if the maximum number of tokens specified in the
                  request was

                  reached.
                enum:
                  - stop
                  - length
        usage:
          type: object
          items:
            $ref: '#/components/schemas/UsageInfo'
    ErrorMessage:
      type: object
      properties:
        error:
          type: string
          description: Error message text
    ChatCompletionRequestMessage:
      type: object
      properties:
        role:
          required: true
          type: string
          enum:
            - system
            - user
            - assistant
          description: >-
            The role of the messages author. One of `system`, `user`, or
            `assistant`.
        content:
          required: true
          oneOf:
            - type: string
              description: >
                The contents of the message. `content` is required for all

                messages, and may be null for assistant messages with function
                calls.
            - type: array
              description: A list of chat messages that could contain images or texts
              items: 8e15778e-d240-4c27-ba7b-5018be9f44c4
        name:
          type: string
          description: >-
            The name of the author of this message. May contain a-z, A-Z, 0-9,
            and underscores, with a maximum length of 64 characters.
    UsageInfo:
      type: object
      description: >
        Usage statistics.


        For streaming responses, `usage` field is included in the very last
        response chunk returned.


        Note that returning `usage` for streaming requests is an OpenAI API
        extension. If you use OpenAI SDK, you might access the field directly
        even if it's not present in the type signature in the SDK.
      properties:
        prompt_tokens:
          type: integer
          description: The number of tokens in the prompt.
        completion_tokens:
          type: integer
          description: The number of tokens in the generated completion.
        total_tokens:
          type: integer
          description: >-
            The total number of tokens used in the request (prompt +
            completion).
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````