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

# Create a text completion

> Create a completion using CompletionRequest. Response is CompletionsResponse.



## OpenAPI

````yaml /api-reference/openapi.json post /v1/completions
openapi: 3.1.0
info:
  title: SynapsAI Inference API
  version: 1.0.0
servers:
  - url: https://api.synapsai.cloud
    description: Production server
security: []
paths:
  /v1/completions:
    post:
      summary: Create a text completion
      description: >-
        Create a completion using CompletionRequest. Response is
        CompletionsResponse.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CompletionRequest'
      responses:
        '200':
          description: Completions response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CompletionsResponse'
components:
  schemas:
    CompletionRequest:
      allOf:
        - type: object
          description: Request body for the text completion endpoint.
          properties:
            prompt:
              type: string
              description: The text prompt to generate completions from. Required.
            images:
              type:
                - array
                - string
                - object
              nullable: true
              description: >-
                Optional images referenced by the prompt (base64, array of
                images or descriptors).
            audios:
              type:
                - array
                - string
                - object
              nullable: true
              description: Optional audio inputs referenced by the prompt.
            videos:
              type:
                - array
                - string
                - object
              nullable: true
              description: Optional video inputs referenced by the prompt.
            max_completion_tokens:
              type: integer
              nullable: true
              description: Maximum tokens to generate for the completion.
            temperature:
              type: number
              nullable: true
              description: Sampling temperature to control randomness of generation.
            top_p:
              type: number
              nullable: true
              description: Nucleus sampling cumulative probability threshold.
            top_k:
              type: integer
              nullable: true
              description: Top-k filtering size to restrict token choices.
            stream:
              type: boolean
              default: false
              description: If true, request streaming partial output as it is produced.
            stop:
              type: array
              items:
                type: string
              nullable: true
              description: List of stop sequences to end generation.
            seed:
              type: integer
              nullable: true
              description: Optional seed to make generation deterministic.
            presence_penalty:
              type: number
              nullable: true
              description: Penalty to reduce likelihood of new tokens based on presence.
            frequency_penalty:
              type: number
              nullable: true
              description: >-
                Penalty to reduce likelihood of tokens appearing based on
                frequency.
            logit_bias:
              type: object
              additionalProperties:
                type: number
              nullable: true
              description: >-
                Token-specific additive biases applied to logits before
                sampling.
            logprobs:
              type: boolean
              default: false
              description: >-
                Whether to include logprob information in the completion
                response.
          required:
            - prompt
    CompletionsResponse:
      type: object
      description: Response returned from the text completions endpoint.
      properties:
        id:
          type: string
          description: Unique identifier for this completion response.
        object:
          type: string
          enum:
            - completion
          default: completion
          description: Type of the returned object; always 'completion' for this response.
        created:
          type: integer
          description: Unix timestamp (seconds) when the completion was created.
        model:
          type: string
          description: Name or ID of the model used to generate the completion.
        choices:
          type: array
          items:
            $ref: '#/components/schemas/Choice'
          description: List of generated choices produced by the model.
        usage:
          $ref: '#/components/schemas/Usage'
          nullable: true
          description: Optional token usage details for this request.
      required:
        - id
        - object
        - created
        - model
        - choices
    Choice:
      type: object
      description: >-
        One generated completion choice with optional logprobs and finish
        reason.
      properties:
        text:
          type: string
          description: The generated text for this choice.
        index:
          type: integer
          description: Index of this choice in the choices list.
        logprobs:
          oneOf:
            - type: number
            - type: array
              items:
                type: number
          nullable: true
          description: >-
            Optional per-token log probability(s) for this choice (if
            requested).
        finish_reason:
          type: string
          nullable: true
          description: Reason the model stopped generation (e.g. 'stop', 'length', null).
    Usage:
      type: object
      description: Token usage counts produced by completion requests.
      properties:
        prompt_tokens:
          type: integer
          description: Number of tokens consumed by the prompt/input.
        completion_tokens:
          type: integer
          description: Number of tokens generated by the model for the completion.
        total_tokens:
          type: integer
          description: Total tokens consumed (prompt_tokens + completion_tokens).

````