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

# Chat Completions

> OpenAI-compatible chat completions endpoint. Supports streaming via the stream parameter.



## OpenAPI

````yaml post /v3/compat/chat/completions
openapi: 3.1.0
info:
  description: Schema-driven generative API that orchestrates LLM-powered workflows.
  title: Task API
  version: 3.0.0
servers:
  - description: Production
    url: https://api.opper.ai
  - description: Local development
    url: http://localhost:8080
security:
  - BearerAuth: []
tags:
  - description: OpenAI-compatible chat completions
    name: Chat
  - description: OpenAI Responses API compatible endpoint
    name: Responses
  - description: Google-compatible interactions endpoint
    name: Interactions
  - description: Model registry and capabilities
    name: Models
  - description: Synchronous image generation
    name: Images
  - description: Text-to-speech and speech-to-text
    name: Audio
  - description: Asynchronous video generation
    name: Videos
  - description: Realtime WebSocket sessions and their ephemeral tickets
    name: Realtime
  - description: Many requests on a provider's batch API at the batch price
    name: Batches
  - description: Reusable file storage for media inputs and generated outputs
    name: Files
  - description: Async generation status and downloads
    name: Artifacts
  - description: >-
      Signed completion webhooks for async jobs, and the project secret that
      signs them
    name: Webhooks
  - description: OpenAI-compatible embeddings
    name: Embeddings
  - description: Recorded HTTP request/response generations
    name: Generations
  - description: System health and status
    name: System
  - description: Roundtable endpoint — fan out a query to multiple LLMs and combine results
    name: Roundtable
  - description: Web search, fetch, and other utility tools
    name: Tools
  - description: Caller identity, credits, and usage
    name: Account
  - description: >-
      Programmatic project and API-key management. Authenticates with an
      `op-mak-…` management token; available on the control_plane and enterprise
      plans.
    name: Management
paths:
  /v3/compat/chat/completions:
    post:
      tags:
        - Compatibility
      summary: Chat Completions API
      description: >-
        OpenAI-compatible chat completions endpoint. Supports streaming via the
        stream parameter.
      operationId: chatCompletions
      parameters:
        - description: >-
            Names the call. The model span takes this name, and so does the
            trace when that span is its root. Up to 256 bytes.
          in: header
          name: X-Opper-Name
          schema:
            type: string
        - description: Parent span ID for distributed tracing context.
          in: header
          name: X-Opper-Parent-Span-Id
          schema:
            format: uuid
            type: string
        - description: >-
            Comma-separated `key:value` usage-attribution tags (e.g.
            `tenant:acme,project:demo`, max 8). Recorded on the generation's
            billing/metrics rows; group spend by any key via GET
            /v2/analytics/usage?group_by=<key>. Header-borne twin of the
            /v3/session URL prefix tags (which win per key when both are
            present); `opper.`-prefixed keys and `session_id` are reserved.
            Malformed values return 400.
          in: header
          name: X-Opper-Tags
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatResponse'
            text/event-stream:
              schema:
                description: >-
                  Server-Sent Events stream. Each event is `data: <json>` (a
                  `chat.completion.chunk` object). The stream terminates with
                  `data: [DONE]`. When `stream_options.include_usage` is true,
                  the final chunk before `[DONE]` carries `usage` and an Opper
                  `cost` extension.
                type: string
          description: Successful response
          headers:
            X-Opper-Cost:
              description: Execution cost of the request as a floating-point number.
              schema:
                format: double
                type: number
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Bad request
        '401':
          description: Unauthorized - missing or invalid API key
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Internal server error
components:
  schemas:
    ChatRequest:
      properties:
        cache_control:
          description: >-
            Opt in to automatic prompt caching for Anthropic-family models:
            {"type":"ephemeral"} (optionally "ttl":"1h"). Places one moving
            cache breakpoint on the largest cacheable prefix. Also settable per
            content part for precise placement. Caching is off unless set; no-op
            on providers with automatic server-side caching (OpenAI
          type: object
        custom_model_credentials:
          properties:
            api_key:
              type: string
            base_url:
              type: string
            extra:
              type: object
            identifier:
              type: string
            url:
              type: string
          required:
            - identifier
            - api_key
          type: object
        max_completion_tokens:
          type: integer
        max_tokens:
          type: integer
        messages:
          items:
            properties:
              content:
                description: Any value
              name:
                type: string
              reasoning_content:
                type: string
              role:
                type: string
              tool_call_id:
                type: string
              tool_calls:
                items:
                  properties:
                    custom:
                      properties:
                        input:
                          type: string
                        name:
                          type: string
                      required:
                        - name
                        - input
                      type: object
                    extra_content:
                      description: Any value
                    function:
                      properties:
                        arguments:
                          type: string
                        name:
                          type: string
                      required:
                        - name
                        - arguments
                      type: object
                    id:
                      type: string
                    thought_signature:
                      type: string
                    type:
                      type: string
                  required:
                    - id
                    - type
                    - function
                  type: object
                type: array
            required:
              - role
              - content
            type: object
          type: array
        metadata:
          type: object
        model:
          type: string
        models:
          description: >-
            Fallback models tried in order when the model before them fails for
            any reason (provider error; rate limit; timeout; a member blocked by
            one of your rules). Same OpenRouter shape: send the primary in model
            and the rest here; or omit model and the first entry is the primary.
            Each entry is any model string: a bare pooled name; a provider/model
            id; an org alias. Not allowed together with a dynamic/<name> route.
            At most 10 entries. Which model answered is in meta.routing.served
            and the X-Opper-Served-Model header; the model field still echoes
            what you sent.
          items:
            type: string
          type: array
        output_schema:
          type: object
        prompt_cache_key:
          description: >-
            OpenAI cache-routing key: a stable name for the prompt prefix this
            request shares with others (e.g. a document id for a fan-out over
            one context). Forwarded to OpenAI and used to keep requests that
            share the key on the same cache replica at providers with
            per-replica prompt caches.
          type: string
        reasoning_effort:
          type: string
        response_format:
          type: object
        service_tier:
          description: >-
            Processing tier. flex: discounted and slower; when the provider has
            no flex capacity the call fails with 429 instead of running at the
            full price. priority (alias fast): faster at a premium; falls back
            to the default tier. ultrafast: fastest; falls back to priority then
            default. economy: the same model cheaper and slower where a provider
            sells it under its own model id; it never falls back to the default
            tier. default and auto: the provider default. A model without an
            endpoint for the requested tier runs at the default tier. The tier
            that ran is in the X-Opper-Served-Service-Tier header.
          type: string
        stop:
          items:
            type: string
          type: array
        stream:
          type: boolean
        stream_options:
          properties:
            include_usage:
              type: boolean
          type: object
        temperature:
          type: number
        tool_choice:
          description: Any value
        tools:
          items:
            properties:
              aspect_ratio:
                type: string
              custom:
                properties:
                  description:
                    type: string
                  format:
                    type: object
                  name:
                    type: string
                required:
                  - name
                type: object
              description:
                type: string
              format:
                type: object
              function:
                properties:
                  description:
                    type: string
                  name:
                    type: string
                  parameters:
                    type: object
                  strict:
                    description: >-
                      Whether the model must follow parameters exactly.
                      Forwarded to providers that enforce it.
                    type: boolean
                required:
                  - name
                type: object
              model:
                type: string
              name:
                type: string
              quality:
                type: string
              size:
                type: string
              style:
                type: string
              type:
                type: string
            required:
              - type
            type: object
          type: array
        top_p:
          type: number
        user:
          description: >-
            OpenAI end-user identifier. Hashed and used as the cache replica
            hint on providers with per-replica prompt caches when neither
            prompt_cache_key nor an X-Session-Affinity header is sent.
          type: string
      required:
        - messages
      type: object
    ChatResponse:
      properties:
        choices:
          items:
            properties:
              finish_reason:
                type: string
              index:
                type: integer
              message:
                properties:
                  annotations:
                    items:
                      properties:
                        type:
                          type: string
                        url_citation:
                          properties:
                            content:
                              type: string
                            end_index:
                              type: integer
                            start_index:
                              type: integer
                            title:
                              type: string
                            url:
                              type: string
                          required:
                            - url
                          type: object
                      required:
                        - type
                      type: object
                    type: array
                  content:
                    type: string
                  reasoning_content:
                    type: string
                  role:
                    type: string
                  tool_calls:
                    items:
                      properties:
                        extra_content:
                          properties:
                            google:
                              properties:
                                thought_signature:
                                  type: string
                              type: object
                          type: object
                        function:
                          properties:
                            arguments:
                              type: string
                            name:
                              type: string
                          required:
                            - name
                            - arguments
                          type: object
                        id:
                          type: string
                        thought_signature:
                          type: string
                        type:
                          type: string
                      required:
                        - id
                        - type
                        - function
                      type: object
                    type: array
                required:
                  - role
                  - content
                type: object
            required:
              - index
              - message
              - finish_reason
            type: object
          type: array
        cost:
          type: number
        created:
          type: integer
        id:
          type: string
        meta:
          properties:
            guards:
              items:
                properties:
                  code:
                    type: string
                  findings:
                    items:
                      description: Any value
                    type: array
                  flagged:
                    type: boolean
                  phase:
                    type: string
                  reason:
                    type: string
                  rule_id:
                    type: string
                  rule_name:
                    type: string
                  scope_type:
                    type: string
                  status:
                    type: string
                  type:
                    type: string
                required:
                  - type
                  - flagged
                type: object
              type: array
            trace_uuid:
              type: string
          type: object
        model:
          type: string
        object:
          type: string
        usage:
          properties:
            completion_tokens:
              type: integer
            completion_tokens_details:
              properties:
                reasoning_tokens:
                  type: integer
              required:
                - reasoning_tokens
              type: object
            prompt_tokens:
              type: integer
            prompt_tokens_details:
              properties:
                cache_creation_1h_tokens:
                  type: integer
                cache_creation_tokens:
                  type: integer
                cached_tokens:
                  type: integer
              type: object
            server_tool_use:
              type: object
            total_tokens:
              type: integer
            usage_buckets:
              additionalProperties:
                type: integer
              type: object
          required:
            - prompt_tokens
            - completion_tokens
            - total_tokens
          type: object
      required:
        - id
        - object
        - created
        - model
        - choices
        - usage
      type: object
    ErrorResponse:
      properties:
        error:
          properties:
            code:
              type: string
            details:
              description: Any value
            message:
              type: string
          required:
            - code
            - message
          type: object
        meta:
          type: object
      required:
        - error
      type: object
  securitySchemes:
    BearerAuth:
      bearerFormat: API Key
      description: API key authentication. Pass your API key as a Bearer token.
      scheme: bearer
      type: http

````

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