# Source: https://docs.openpipe.ai/api-reference/post-chatcompletions.md

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

# Chat Completions

> OpenAI-compatible route for generating inference and optionally logging the request.



## OpenAPI

````yaml post /chat/completions
openapi: 3.0.3
info:
  title: OpenPipe API
  description: The public API for reporting API calls to OpenPipe
  version: 0.1.1
servers:
  - url: https://api.openpipe.ai/api/v1
security: []
paths:
  /chat/completions:
    post:
      description: >-
        OpenAI-compatible route for generating inference and optionally logging
        the request.
      operationId: createChatCompletion
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                messages:
                  type: array
                  items:
                    anyOf:
                      - type: object
                        properties:
                          role:
                            type: string
                            enum:
                              - system
                          content:
                            anyOf:
                              - type: string
                              - type: array
                                items:
                                  type: object
                                  properties:
                                    type:
                                      type: string
                                      enum:
                                        - text
                                    text:
                                      type: string
                                  required:
                                    - type
                                    - text
                                  additionalProperties: false
                            default: ''
                          name:
                            type: string
                        required:
                          - role
                        additionalProperties: false
                      - type: object
                        properties:
                          role:
                            type: string
                            enum:
                              - user
                          content:
                            anyOf:
                              - type: string
                              - type: array
                                items:
                                  anyOf:
                                    - type: object
                                      properties:
                                        type:
                                          type: string
                                          enum:
                                            - text
                                        text:
                                          type: string
                                      required:
                                        - type
                                        - text
                                      additionalProperties: false
                                    - type: object
                                      properties:
                                        type:
                                          type: string
                                          enum:
                                            - image_url
                                        image_url:
                                          type: object
                                          properties:
                                            detail:
                                              anyOf:
                                                - type: string
                                                  enum:
                                                    - auto
                                                - type: string
                                                  enum:
                                                    - low
                                                - type: string
                                                  enum:
                                                    - high
                                            url:
                                              type: string
                                          required:
                                            - url
                                          additionalProperties: false
                                      required:
                                        - type
                                        - image_url
                                      additionalProperties: false
                                    - type: object
                                      properties:
                                        type:
                                          type: string
                                          enum:
                                            - input_audio
                                        input_audio:
                                          type: object
                                          properties:
                                            data:
                                              type: string
                                            format:
                                              type: string
                                              enum:
                                                - wav
                                                - mp3
                                          required:
                                            - data
                                            - format
                                          additionalProperties: false
                                      required:
                                        - type
                                        - input_audio
                                      additionalProperties: false
                            default: ''
                          name:
                            type: string
                        required:
                          - role
                        additionalProperties: false
                      - type: object
                        properties:
                          role:
                            type: string
                            enum:
                              - assistant
                          audio:
                            type: object
                            properties:
                              id:
                                type: string
                            required:
                              - id
                            additionalProperties: false
                            nullable: true
                          content:
                            anyOf:
                              - type: string
                              - type: array
                                items:
                                  anyOf:
                                    - type: object
                                      properties:
                                        type:
                                          type: string
                                          enum:
                                            - text
                                        text:
                                          type: string
                                      required:
                                        - type
                                        - text
                                      additionalProperties: false
                                    - type: object
                                      properties:
                                        type:
                                          type: string
                                          enum:
                                            - refusal
                                        refusal:
                                          type: string
                                      required:
                                        - type
                                        - refusal
                                      additionalProperties: false
                              - enum:
                                  - 'null'
                                nullable: true
                            default: null
                          function_call:
                            type: object
                            properties:
                              name:
                                type: string
                                default: ''
                              arguments:
                                type: string
                                default: ''
                            additionalProperties: false
                            nullable: true
                          tool_calls:
                            type: array
                            items:
                              type: object
                              properties:
                                id:
                                  type: string
                                function:
                                  type: object
                                  properties:
                                    name:
                                      type: string
                                    arguments:
                                      type: string
                                  required:
                                    - name
                                    - arguments
                                  additionalProperties: false
                                type:
                                  type: string
                                  enum:
                                    - function
                              required:
                                - id
                                - function
                                - type
                              additionalProperties: false
                            nullable: true
                          name:
                            type: string
                          refusal:
                            type: string
                            nullable: true
                          annotations:
                            type: array
                            items:
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - url_citation
                                url_citation:
                                  type: object
                                  properties:
                                    start_index:
                                      type: number
                                    end_index:
                                      type: number
                                    title:
                                      type: string
                                    url:
                                      type: string
                                  required:
                                    - start_index
                                    - end_index
                                    - title
                                    - url
                                  additionalProperties: false
                              required:
                                - type
                                - url_citation
                              additionalProperties: false
                        required:
                          - role
                        additionalProperties: false
                      - type: object
                        properties:
                          role:
                            type: string
                            enum:
                              - developer
                          content:
                            anyOf:
                              - type: string
                              - type: array
                                items:
                                  type: object
                                  properties:
                                    type:
                                      type: string
                                      enum:
                                        - text
                                    text:
                                      type: string
                                  required:
                                    - type
                                    - text
                                  additionalProperties: false
                            default: ''
                          name:
                            type: string
                        required:
                          - role
                        additionalProperties: false
                      - type: object
                        properties:
                          role:
                            type: string
                            enum:
                              - tool
                          content:
                            anyOf:
                              - type: string
                              - type: array
                                items:
                                  type: object
                                  properties:
                                    type:
                                      type: string
                                      enum:
                                        - text
                                    text:
                                      type: string
                                  required:
                                    - type
                                    - text
                                  additionalProperties: false
                            default: ''
                          tool_call_id:
                            type: string
                        required:
                          - role
                          - tool_call_id
                        additionalProperties: false
                      - type: object
                        properties:
                          role:
                            type: string
                            enum:
                              - function
                          name:
                            type: string
                          content:
                            anyOf:
                              - type: string
                              - enum:
                                  - 'null'
                                nullable: true
                        required:
                          - role
                          - name
                          - content
                        additionalProperties: false
                model:
                  type: string
                audio:
                  type: object
                  properties:
                    format:
                      type: string
                      enum:
                        - wav
                        - mp3
                        - flac
                        - opus
                        - pcm16
                    voice:
                      type: string
                      enum:
                        - alloy
                        - ash
                        - ballad
                        - coral
                        - echo
                        - sage
                        - shimmer
                        - verse
                  required:
                    - format
                    - voice
                  additionalProperties: false
                  nullable: true
                function_call:
                  anyOf:
                    - type: string
                      enum:
                        - none
                    - type: string
                      enum:
                        - auto
                    - type: object
                      properties:
                        name:
                          type: string
                      required:
                        - name
                      additionalProperties: false
                functions:
                  type: array
                  items:
                    type: object
                    properties:
                      name:
                        type: string
                      parameters:
                        type: object
                        additionalProperties: {}
                      description:
                        type: string
                      strict:
                        type: boolean
                        nullable: true
                    required:
                      - name
                    additionalProperties: false
                tool_choice:
                  anyOf:
                    - type: string
                      enum:
                        - none
                    - type: string
                      enum:
                        - auto
                    - type: string
                      enum:
                        - required
                    - type: object
                      properties:
                        type:
                          type: string
                          enum:
                            - function
                          default: function
                        function:
                          type: object
                          properties:
                            name:
                              type: string
                          required:
                            - name
                          additionalProperties: false
                          default:
                            name: ''
                      additionalProperties: false
                tools:
                  type: array
                  items:
                    type: object
                    properties:
                      function:
                        type: object
                        properties:
                          name:
                            type: string
                          parameters:
                            type: object
                            additionalProperties: {}
                          description:
                            type: string
                          strict:
                            type: boolean
                            nullable: true
                        required:
                          - name
                        additionalProperties: false
                      type:
                        type: string
                        enum:
                          - function
                    required:
                      - function
                      - type
                    additionalProperties: false
                'n':
                  type: number
                max_tokens:
                  type: number
                  nullable: true
                max_completion_tokens:
                  type: number
                  nullable: true
                temperature:
                  type: number
                top_p:
                  type: number
                  nullable: true
                presence_penalty:
                  type: number
                  nullable: true
                frequency_penalty:
                  type: number
                  nullable: true
                stop:
                  anyOf:
                    - type: string
                    - type: array
                      items:
                        type: string
                  nullable: true
                response_format:
                  anyOf:
                    - type: object
                      properties:
                        type:
                          type: string
                          enum:
                            - text
                      required:
                        - type
                      additionalProperties: false
                    - type: object
                      properties:
                        type:
                          type: string
                          enum:
                            - json_object
                      required:
                        - type
                      additionalProperties: false
                    - type: object
                      properties:
                        type:
                          type: string
                          enum:
                            - json_schema
                        json_schema:
                          type: object
                          properties:
                            name:
                              type: string
                            description:
                              type: string
                            schema:
                              type: object
                              additionalProperties: {}
                            strict:
                              type: boolean
                              nullable: true
                          required:
                            - name
                          additionalProperties: false
                      required:
                        - type
                        - json_schema
                      additionalProperties: false
                logprobs:
                  type: boolean
                top_logprobs:
                  type: number
                  nullable: true
                stream_options:
                  type: object
                  properties:
                    include_usage:
                      type: boolean
                  required:
                    - include_usage
                  additionalProperties: false
                store:
                  type: boolean
                metadata:
                  type: object
                  additionalProperties:
                    type: string
                  nullable: true
                stream:
                  type: boolean
                  default: false
              required:
                - messages
                - model
              additionalProperties: true
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                anyOf:
                  - type: object
                    properties:
                      id:
                        type: string
                      object:
                        type: string
                        enum:
                          - chat.completion
                      created:
                        type: number
                      model:
                        type: string
                      choices:
                        type: array
                        items:
                          type: object
                          properties:
                            finish_reason:
                              anyOf:
                                - type: string
                                  enum:
                                    - length
                                - type: string
                                  enum:
                                    - function_call
                                - type: string
                                  enum:
                                    - tool_calls
                                - type: string
                                  enum:
                                    - stop
                                - type: string
                                  enum:
                                    - content_filter
                            index:
                              type: number
                            message:
                              type: object
                              properties:
                                reasoning_content:
                                  type: string
                                  nullable: true
                                content:
                                  type: string
                                  nullable: true
                                  default: null
                                refusal:
                                  type: string
                                  nullable: true
                                role:
                                  type: string
                                  enum:
                                    - assistant
                                function_call:
                                  type: object
                                  properties:
                                    name:
                                      type: string
                                      default: ''
                                    arguments:
                                      type: string
                                      default: ''
                                  additionalProperties: false
                                  nullable: true
                                tool_calls:
                                  type: array
                                  items:
                                    type: object
                                    properties:
                                      id:
                                        type: string
                                      function:
                                        type: object
                                        properties:
                                          name:
                                            type: string
                                          arguments:
                                            type: string
                                        required:
                                          - name
                                          - arguments
                                        additionalProperties: false
                                      type:
                                        type: string
                                        enum:
                                          - function
                                    required:
                                      - id
                                      - function
                                      - type
                                    additionalProperties: false
                                  nullable: true
                              required:
                                - role
                              additionalProperties: false
                            logprobs:
                              type: object
                              properties:
                                content:
                                  type: array
                                  items:
                                    type: object
                                    properties:
                                      token:
                                        type: string
                                      bytes:
                                        type: array
                                        items:
                                          type: number
                                        nullable: true
                                      logprob:
                                        type: number
                                      top_logprobs:
                                        type: array
                                        items:
                                          type: object
                                          properties:
                                            token:
                                              type: string
                                            bytes:
                                              type: array
                                              items:
                                                type: number
                                              nullable: true
                                            logprob:
                                              type: number
                                          required:
                                            - token
                                            - bytes
                                            - logprob
                                          additionalProperties: false
                                    required:
                                      - token
                                      - bytes
                                      - logprob
                                      - top_logprobs
                                    additionalProperties: false
                                  nullable: true
                                  default: null
                                refusal:
                                  type: array
                                  items:
                                    type: object
                                    properties:
                                      token:
                                        type: string
                                      bytes:
                                        type: array
                                        items:
                                          type: number
                                        nullable: true
                                      logprob:
                                        type: number
                                      top_logprobs:
                                        type: array
                                        items:
                                          type: object
                                          properties:
                                            token:
                                              type: string
                                            bytes:
                                              type: array
                                              items:
                                                type: number
                                              nullable: true
                                            logprob:
                                              type: number
                                          required:
                                            - token
                                            - bytes
                                            - logprob
                                          additionalProperties: false
                                    required:
                                      - token
                                      - bytes
                                      - logprob
                                      - top_logprobs
                                    additionalProperties: false
                                  nullable: true
                                  default: null
                              additionalProperties: false
                              nullable: true
                              default: null
                            content_filter_results:
                              type: object
                              properties: {}
                              additionalProperties: true
                            criteria_results:
                              type: object
                              additionalProperties:
                                anyOf:
                                  - type: object
                                    properties:
                                      status:
                                        type: string
                                        enum:
                                          - success
                                      score:
                                        type: number
                                      explanation:
                                        type: string
                                      errorCode:
                                        type: number
                                      errorMessage:
                                        type: string
                                    required:
                                      - status
                                      - score
                                    additionalProperties: false
                                  - type: object
                                    properties:
                                      status:
                                        type: string
                                        enum:
                                          - error
                                      score:
                                        type: number
                                      explanation:
                                        type: string
                                      errorCode:
                                        type: number
                                      errorMessage:
                                        type: string
                                    required:
                                      - status
                                      - errorCode
                                      - errorMessage
                                    additionalProperties: false
                          required:
                            - finish_reason
                            - index
                            - message
                          additionalProperties: false
                      usage:
                        type: object
                        properties:
                          prompt_tokens:
                            type: number
                          completion_tokens:
                            type: number
                          total_tokens:
                            type: number
                          prompt_cache_hit_tokens:
                            type: number
                          prompt_cache_miss_tokens:
                            type: number
                          completion_tokens_details:
                            type: object
                            properties:
                              reasoning_tokens:
                                type: number
                                nullable: true
                              audio_tokens:
                                type: number
                                nullable: true
                              text_tokens:
                                type: number
                                nullable: true
                              accepted_prediction_tokens:
                                type: number
                                nullable: true
                              rejected_prediction_tokens:
                                type: number
                                nullable: true
                            additionalProperties: false
                            nullable: true
                          prompt_tokens_details:
                            type: object
                            properties:
                              cached_tokens:
                                type: number
                                nullable: true
                              audio_tokens:
                                type: number
                                nullable: true
                            additionalProperties: false
                            nullable: true
                          criteria:
                            type: object
                            additionalProperties:
                              type: object
                              properties:
                                total_tokens:
                                  type: number
                                  description: >-
                                    The total number of tokens used to generate
                                    the criterion judgement. Only returned for
                                    OpenPipe-trained reward models currently.
                              required:
                                - total_tokens
                              additionalProperties: false
                        required:
                          - prompt_tokens
                          - completion_tokens
                          - total_tokens
                        additionalProperties: false
                    required:
                      - id
                      - object
                      - created
                      - model
                      - choices
                    additionalProperties: false
                    nullable: true
                  - {}
        default:
          $ref: '#/components/responses/error'
      security:
        - Authorization: []
components:
  responses:
    error:
      description: Error response
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
              code:
                type: string
              issues:
                type: array
                items:
                  type: object
                  properties:
                    message:
                      type: string
                  required:
                    - message
                  additionalProperties: false
            required:
              - message
              - code
            additionalProperties: false
  securitySchemes:
    Authorization:
      type: http
      scheme: bearer

````