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

# Create a chat completion

> An LLM model answers an OpenAI Chat Completions body.

It returns the answer in the HTTP response, or as server-sent events with `stream: true`.
For robot action models, use [get\_action](https://abstract-pbc.mintlify.site/robots/get-action.md).


## OpenAPI

````yaml /api-reference/openapi.yaml post /v1/chat/completions
openapi: 3.1.0
info:
  title: Abstract API
  version: 1.0.0
  summary: Robot action models and LLMs behind one API key.
  description: >
    `POST /v1/chat/completions` serves the LLM models. `GET
    /v1/chat/completions/{completion_id}`

    reads an LLM completion your account created. `POST /v1/get_action` and
    `POST /v1/end_session`

    serve the robot action models in Dream Labs' request shape. `GET /v1/models`
    lists the LLM model ids.
  contact:
    name: Abstract
    url: https://abstract.inc
servers:
  - url: https://api.abstract.inc
security:
  - bearerAuth: []
tags:
  - name: Chat completions
  - name: Robot actions
    description: End-effector and model-specific native joint action contracts.
  - name: Catalog
  - name: CLI credentials
paths:
  /v1/chat/completions:
    post:
      tags:
        - Chat completions
      summary: Create a chat completion
      description: >
        An LLM model answers an OpenAI Chat Completions body.


        It returns the answer in the HTTP response, or as server-sent events
        with `stream: true`.

        For robot action models, use [get_action](/robots/get-action).
      operationId: createChatCompletion
      parameters:
        - $ref: '#/components/parameters/AbstractVersion'
        - name: Idempotency-Key
          in: header
          required: false
          description: >-
            The same POST with the same key returns the same answer and never
            starts a second job. 1 to 200 characters from `A-Z a-z 0-9 _ . / :
            -`.
          schema:
            type: string
            pattern: ^[A-Za-z0-9_./:-]{1,200}$
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LlmChatCompletionRequest'
            examples:
              stream:
                summary: glm-5.3-flash, streamed live
                value:
                  model: glm-5.3-flash
                  stream: true
                  messages:
                    - role: user
                      content: Write a haiku about a robot arm.
              llm:
                summary: glm-5.3, answered inline
                value:
                  model: glm-5.3
                  messages:
                    - role: system
                      content: Answer in three sentences.
                    - role: user
                      content: Summarise RFC 8628.
      responses:
        '200':
          description: The LLM chat completion.
          headers:
            Idempotency-Key:
              description: >-
                LLM models. The key this request ran under. The API generates
                one when you send none.
              schema:
                type: string
            X-Generation-Id:
              description: The id of this generation.
              schema:
                type: string
            Request-Id:
              $ref: '#/components/headers/RequestId'
            Abstract-Version:
              $ref: '#/components/headers/AbstractVersion'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatCompletion'
              example:
                id: gen-3f9a1c2b7d4e
                object: chat.completion
                created: 1790000000
                model: glm-5.3-flash
                choices:
                  - index: 0
                    message:
                      role: assistant
                      content: A robot arm folds a towel.
                    finish_reason: stop
                usage:
                  prompt_tokens: 650
                  prompt_tokens_details:
                    cached_tokens: 0
                  completion_tokens: 30
                  total_tokens: 680
            text/event-stream:
              schema:
                type: string
                description: >-
                  Server-sent events. Lines that start with `:` are comments.
                  The stream ends with `data: [DONE]`.
              example: >
                data:
                {"id":"gen-3f9a1c2b7d4e","object":"chat.completion.chunk","created":1790000000,"model":"glm-5.3-flash","choices":[{"index":0,"delta":{"role":"assistant","content":"A
                robot arm folds a towel."},"finish_reason":null}]}


                data:
                {"id":"gen-3f9a1c2b7d4e","object":"chat.completion.chunk","created":1790000000,"model":"glm-5.3-flash","choices":[{"index":0,"delta":{},"finish_reason":"stop"}],"usage":{"prompt_tokens":650,"prompt_tokens_details":{"cached_tokens":0},"completion_tokens":30,"total_tokens":680}}


                data: [DONE]
        '400':
          description: >-
            `use_get_action`: `model` is a robot model id. Robot models are
            served at [`POST /v1/get_action`](/robots/get-action) only.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  message: >-
                    Robot models are served at POST /v1/get_action, not
                    /v1/chat/completions.
                  type: invalid_request_error
                  code: use_get_action
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          $ref: '#/components/responses/PaymentRequired'
        '409':
          description: >-
            `idempotency_conflict`, `idempotency_replay_terminal` or
            `submission_outcome_unknown`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '413':
          description: '`invalid_request`: an LLM body over 2 MiB.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: >-
            LLM models: `invalid_request` (unknown model, or an unsupported
            field such as `tools` or `stop`) or `invalid_idempotency_key`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: >-
            `spend_limit_exceeded` (do not retry), `pass_limit_reached` (the
            account's Abstract Pass limit is used up until `error.resets_at`; do
            not retry before then) or `no_replica_free` (retry after
            `Retry-After` seconds with the same `Idempotency-Key`).
          headers:
            Retry-After:
              description: >-
                Seconds to wait before sending the request again. Sent with
                `no_replica_free`.
              schema:
                type: integer
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '502':
          description: >-
            `invalid_upstream_response` or `upstream_failed`: an LLM model did
            not complete the request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '503':
          $ref: '#/components/responses/Unavailable'
components:
  parameters:
    AbstractVersion:
      name: Abstract-Version
      in: header
      required: false
      description: >-
        The API version your client was written for. `2026-10-27` is the only
        version. Without this header the request is answered under the newest
        version; a version the API does not answer is refused with `400
        unsupported_api_version` before anything runs.
      schema:
        type: string
        enum:
          - '2026-10-27'
  schemas:
    LlmChatCompletionRequest:
      type: object
      title: LLM model
      required:
        - model
        - messages
      additionalProperties: false
      properties:
        model:
          type: string
          enum:
            - kimi-k3.1-pro
            - glm-5.3
            - glm-5.3-flash
            - deepseek-v4.1-flash
        messages:
          type: array
          minItems: 1
          description: >-
            `role` is `system`, `developer`, `user` or `assistant`. `content` is
            a string or an array of `text` parts; a `user` message can also
            carry `image_url` parts, each a base64 `data:` URL.
          items:
            type: object
            required:
              - role
              - content
        max_completion_tokens:
          type: integer
          minimum: 1
          maximum: 65536
          default: 65536
          description: Counts the model's reasoning as well as its answer.
        max_tokens:
          type: integer
          minimum: 1
          maximum: 65536
          description: The same as `max_completion_tokens`.
        stream:
          type: boolean
          default: false
          description: Live server-sent events.
        stream_options:
          type: object
          description: >-
            Accepted. Usage always arrives in its own chunk before `data:
            [DONE]`.
        response_format:
          type: object
          description: >-
            `text`, `json_object`, or `json_schema` with a named `json_schema`
            object.
        reasoning_effort:
          type: string
        temperature:
          type: number
        top_p:
          type: number
        user:
          type: string
        metadata:
          type: object
          additionalProperties:
            type: string
        prompt_cache_key:
          type: string
        'n':
          type: integer
          const: 1
        store:
          type: boolean
          const: false
    ChatCompletion:
      type: object
      required:
        - id
        - object
        - created
        - model
        - choices
        - usage
      properties:
        id:
          type: string
        object:
          type: string
          const: chat.completion
        created:
          type: integer
          description: Unix seconds.
        model:
          type: string
        choices:
          type: array
          items:
            type: object
            properties:
              index:
                type: integer
              message:
                type: object
                properties:
                  role:
                    type: string
                    const: assistant
                  content:
                    type:
                      - string
                      - 'null'
                    description: The LLM answer.
                  reasoning_content:
                    type: string
                    description: LLM models. The model's reasoning, when it reports it.
                  refusal:
                    type: string
                    description: LLM models. The model's refusal, when it refuses.
              finish_reason:
                type: string
                enum:
                  - stop
                  - length
                  - content_filter
                  - error
        usage:
          $ref: '#/components/schemas/ChunkUsage'
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - message
            - type
            - code
            - retryable
            - retry_after_s
            - request_id
          properties:
            message:
              type: string
              description: For people. It can change.
            type:
              type: string
            param:
              type:
                - string
                - 'null'
              description: The request field at fault, when one is.
            code:
              type: string
              description: Branch on this. See [Errors and limits](/errors).
            retryable:
              type: boolean
              description: >-
                Whether this same request may be sent again. When the route
                gives no answer of its own, `true` for 408, 429 and 503.
            retry_after_s:
              type:
                - number
                - 'null'
              description: The `Retry-After` header in seconds, or `null`.
            request_id:
              type: string
              pattern: ^req_[0-9a-f]{32}$
              description: >-
                This answer's `Request-Id` header. Quote it when you report a
                problem.
    ChunkUsage:
      type: object
      required:
        - prompt_tokens
        - completion_tokens
        - total_tokens
      properties:
        prompt_tokens:
          type: integer
          description: >-
            Prompt tokens, cached ones included. For a robot model, the model's
            prompt tokens for the chunk.
        prompt_tokens_details:
          type: object
          properties:
            cached_tokens:
              type: integer
              description: >-
                The part of `prompt_tokens` served from cache. For a robot
                model, reused from earlier chunks of the episode.
        completion_tokens:
          type: integer
          description: >-
            Output tokens. For a robot model, the action rows the model
            computed, before any `action_horizon` cut.
        total_tokens:
          type: integer
  headers:
    RequestId:
      description: >-
        `req_` and 32 hex characters, new for each HTTP attempt, a retry
        included. An error repeats it as `error.request_id`. Quote it when you
        report a problem.
      schema:
        type: string
        pattern: ^req_[0-9a-f]{32}$
    AbstractVersion:
      description: >-
        The API version this answer was made under: the `Abstract-Version` the
        request sent, or the newest version when it sent none.
      schema:
        type: string
  responses:
    Unauthorized:
      description: '`missing_api_key` or `invalid_api_key`.'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              message: Invalid API key.
              type: invalid_request_error
              code: invalid_api_key
    PaymentRequired:
      description: >-
        `payment_required`: the account has no payment method and no credit.
        `insufficient_credit`: available credit cannot cover the inference
        reservation. A saved payment method alone does not fund usage.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unavailable:
      description: >-
        A dependency is down, for example `auth_unavailable`,
        `billing_unavailable`, `metering_unavailable` or `engine_unavailable`.
        Retry with backoff.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Your Abstract API key. Get it with `abstract login`, pass it as
        `$(abstract token)`.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.