> ## 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: Schema-driven function management and execution
    name: Functions
  - 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: Reusable file storage for media inputs and generated outputs
    name: Files
  - description: Async generation status and downloads
    name: Artifacts
  - 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
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: >-
            Function name for tracing and project-level guardrail function-scope
            filtering.
          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
      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:
        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
              role:
                type: string
              tool_call_id:
                type: string
              tool_calls:
                items:
                  properties:
                    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
        model:
          type: string
        output_schema:
          type: object
        reasoning_effort:
          type: string
        response_format:
          type: object
        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
              function:
                properties:
                  description:
                    type: string
                  name:
                    type: string
                  parameters:
                    type: object
                required:
                  - name
                type: object
              model:
                type: string
              quality:
                type: string
              size:
                type: string
              style:
                type: string
              type:
                type: string
            required:
              - type
            type: object
          type: array
        top_p:
          type: number
      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:
                        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
                  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
          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

````