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

# Create completion

> Query a language, code, or image model.



## OpenAPI

````yaml together-openapi.yaml post /completions
openapi: 3.0.0
info:
  title: Together API
  description: The Together REST API. Please see https://docs.together.ai for more details.
  version: 2.0.0
  termsOfService: https://www.together.ai/terms-of-service
  contact:
    name: Together Support
    url: https://www.together.ai/contact
  license:
    name: MIT
    url: https://github.com/togethercomputer/openapi/blob/main/LICENSE
servers:
  - url: https://api.together.xyz/v1
security:
  - bearerAuth: []
paths:
  /completions:
    post:
      tags:
        - Completion
      summary: Create completion
      description: Query a language, code, or image model.
      operationId: completions
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CompletionRequest'
      responses:
        '200':
          description: '200'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CompletionResponse'
            text/event-stream:
              schema:
                $ref: '#/components/schemas/CompletionStream'
        '400':
          description: BadRequest
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorData'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorData'
        '404':
          description: NotFound
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorData'
        '429':
          description: RateLimit
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorData'
        '503':
          description: Overloaded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorData'
        '504':
          description: Timeout
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorData'
      deprecated: false
components:
  schemas:
    CompletionRequest:
      type: object
      required:
        - model
        - prompt
      properties:
        prompt:
          type: string
          description: A string providing context for the model to complete.
          example: <s>[INST] What is the capital of France? [/INST]
        model:
          type: string
          description: The name of the model to query.
          example: mistralai/Mixtral-8x7B-Instruct-v0.1
        max_tokens:
          type: integer
          description: The maximum number of tokens to generate.
        stop:
          type: array
          description: >-
            A list of string sequences that will truncate (stop) inference text
            output.
          items:
            type: string
        temperature:
          type: number
          description: Determines the degree of randomness in the response.
          format: float
        top_p:
          type: number
          description: >-
            The `top_p` (nucleus) parameter is used to dynamically adjust the
            number of choices for each predicted token based on the cumulative
            probabilities.
          format: float
        top_k:
          type: integer
          description: >-
            The `top_k` parameter is used to limit the number of choices for the
            next predicted word or token.
          format: int32
        repetition_penalty:
          type: number
          description: >-
            A number that controls the diversity of generated text by reducing
            the likelihood of repeated sequences. Higher values decrease
            repetition.
          format: float
        stream:
          type: boolean
          description: >-
            If set, tokens are returned as Server-Sent Events as they are made
            available. Stream terminates with `data: [DONE]`
        logprobs:
          type: integer
          minimum: 0
          maximum: 1
          description: >-
            Determines the number of most likely tokens to return at each token
            position log probabilities to return
        echo:
          type: boolean
          description: >-
            If set, the response will contain the prompt, and will also return
            prompt logprobs if set with logprobs.
        'n':
          type: integer
          description: Number of generations to return
          minimum: 1
          maximum: 128
        safety_model:
          type: string
          description: The name of the safety model to use.
          example: safety_model_name
        min_p:
          type: number
          description: >-
            The `min_p` parameter is a number between 0 and 1 and an alternative
            to `temperature`.
          format: float
        presence_penalty:
          type: number
          description: >-
            The `presence_penalty` parameter is a number between -2.0 and 2.0
            where a positive value will increase the likelihood of a model
            talking about new topics.
          format: float
        frequency_penalty:
          type: number
          description: >-
            The `frequency_penalty` parameter is a number between -2.0 and 2.0
            where a positive value will decrease the likelihood of repeating
            tokens that were mentioned prior.
          format: float
        logit_bias:
          type: object
          additionalProperties:
            type: number
            format: float
          description: >-
            The `logit_bias` parameter allows us to adjust the likelihood of
            specific tokens appearing in the generated output.
          example:
            '105': 21.4
            '1024': -10.5
    CompletionResponse:
      type: object
      properties:
        id:
          type: string
        choices:
          $ref: '#/components/schemas/CompletionChoicesData'
        prompt:
          $ref: '#/components/schemas/PromptPart'
        usage:
          $ref: '#/components/schemas/UsageData'
        created:
          type: integer
        model:
          type: string
        object:
          type: string
          enum:
            - text_completion
      required:
        - id
        - choices
        - usage
        - created
        - model
        - object
    CompletionStream:
      oneOf:
        - $ref: '#/components/schemas/CompletionEvent'
        - $ref: '#/components/schemas/StreamSentinel'
    ErrorData:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              nullable: false
            type:
              type: string
              nullable: false
            param:
              type: string
              nullable: true
              default: null
            code:
              type: string
              nullable: true
              default: null
          required:
            - type
            - message
            - param
            - code
    CompletionChoicesData:
      type: array
      items:
        type: object
        properties:
          text:
            type: string
            example: >-
              The capital of France is Paris. It's located in the north-central
              part of the country and is one of the most populous and visited
              cities in the world, known for its iconic landmarks like the
              Eiffel Tower, Louvre Museum, Notre-Dame Cathedral, and more. Paris
              is also the capital of the Île-de-France region and is a major
              global center for art, fashion, gastronomy, and culture.
          finish_reason:
            $ref: '#/components/schemas/FinishReason'
          logprobs:
            allOf:
              - $ref: '#/components/schemas/LogprobsPart'
              - nullable: true
    PromptPart:
      type: array
      items:
        type: object
        properties:
          text:
            type: string
            example: <s>[INST] What is the capital of France? [/INST]
          logprobs:
            $ref: '#/components/schemas/LogprobsPart'
    UsageData:
      type: object
      properties:
        prompt_tokens:
          type: integer
        completion_tokens:
          type: integer
        total_tokens:
          type: integer
      required:
        - prompt_tokens
        - completion_tokens
        - total_tokens
      nullable: true
    CompletionEvent:
      type: object
      required:
        - data
      properties:
        data:
          $ref: '#/components/schemas/CompletionChunk'
    StreamSentinel:
      type: object
      required:
        - data
      properties:
        data:
          title: stream_signal
          type: string
          enum:
            - '[DONE]'
    FinishReason:
      type: string
      enum:
        - stop
        - eos
        - length
        - tool_calls
    LogprobsPart:
      type: object
      properties:
        tokens:
          type: array
          items:
            type: string
          description: List of token strings
        token_logprobs:
          type: array
          items:
            type: number
            format: float
          description: List of token log probabilities
    CompletionChunk:
      type: object
      required:
        - id
        - token
        - choices
        - usage
        - finish_reason
      properties:
        id:
          type: string
        token:
          $ref: '#/components/schemas/CompletionToken'
        choices:
          title: CompletionChoices
          type: array
          items:
            $ref: '#/components/schemas/CompletionChoice'
        usage:
          allOf:
            - $ref: '#/components/schemas/UsageData'
            - nullable: true
        finish_reason:
          allOf:
            - $ref: '#/components/schemas/FinishReason'
            - nullable: true
    CompletionToken:
      type: object
      required:
        - id
        - text
        - logprob
        - special
      properties:
        id:
          type: integer
        text:
          type: string
        logprob:
          type: number
          format: float
        special:
          type: boolean
    CompletionChoice:
      type: object
      required:
        - index
      properties:
        text:
          type: string
  securitySchemes:
    bearerAuth:
      type: apiKey
      in: header
      name: Authorization
      x-bearer-format: bearer
      x-default: default

````