> ## 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.

# Completions

> Creates a completion for the provided prompt and parameters.



## OpenAPI

````yaml https://dev-platform.algo-tech.ai/api/openapi post /v1/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/completions:
    post:
      summary: Completions
      description: Creates a completion for the provided prompt and parameters.
      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/CreateCompletions'
      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:
    CreateCompletions:
      type: object
      properties:
        model:
          required: true
          type: string
          description: The name of the model to use.
          example: deepseek-ai/DeepSeek-R1
        prompt:
          required: true
          type: string
          description: >-
            The prompt to generate completions for.

            It can be a single string or an array of strings.

            It can also be an array of integers or an array of integer arrays,

            which allows to pass already tokenized prompt.

            If multiple prompts are specified, several choices with
            corresponding index will be returned in the output."
          example: The sky is
        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
    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

````