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

# Text completions

> OpenAI-compatible legacy completions endpoint. Prefer
[chat completions](/api-reference/chat-completions) for new code.




## OpenAPI

````yaml POST /v1/completions
openapi: 3.0.3
info:
  title: Tera API
  description: >
    OpenAI-compatible inference API. Existing OpenAI SDKs work without
    modification —

    point them at `https://api.tera.gw` with your Tera API key.
  version: 1.0.0
servers:
  - url: https://api.tera.gw
    description: Production
security:
  - bearerAuth: []
tags:
  - name: chat
    description: Chat completions
  - name: completions
    description: Text completions
  - name: models
    description: Model catalog
  - name: audio
    description: Text-to-speech
paths:
  /v1/completions:
    post:
      tags:
        - completions
      summary: Create a text completion
      description: |
        OpenAI-compatible legacy completions endpoint. Prefer
        [chat completions](/api-reference/chat-completions) for new code.
      operationId: createCompletion
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CompletionRequest'
      responses:
        '200':
          description: 'A text completion (or an SSE stream when `stream: true`).'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CompletionResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/ServerError'
components:
  schemas:
    CompletionRequest:
      type: object
      required:
        - model
        - prompt
      properties:
        model:
          type: string
          example: Qwen/Qwen2.5-7B-Instruct
        prompt:
          oneOf:
            - type: string
            - type: array
              items:
                type: string
        max_tokens:
          type: integer
          example: 64
        temperature:
          type: number
        top_p:
          type: number
        top_k:
          type: integer
        stop:
          oneOf:
            - type: string
            - type: array
              items:
                type: string
        seed:
          type: integer
        stream:
          type: boolean
          default: false
    CompletionResponse:
      type: object
      properties:
        id:
          type: string
        object:
          type: string
          example: text_completion
        created:
          type: integer
        model:
          type: string
        choices:
          type: array
          items:
            type: object
            properties:
              text:
                type: string
              index:
                type: integer
              finish_reason:
                type: string
                enum:
                  - stop
                  - length
        usage:
          type: object
          properties:
            prompt_tokens:
              type: integer
            completion_tokens:
              type: integer
            total_tokens:
              type: integer
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            type:
              type: string
            code:
              type: string
  responses:
    BadRequest:
      description: Malformed request.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: Missing or invalid API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    NotFound:
      description: Model not found or not deployed.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    RateLimited:
      description: Too many requests.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    ServerError:
      description: Backend failure after retries.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: sk-tera-...

````