---
title: "POST /chat/completions"
method: POST
path: "/chat/completions"
---

# POST /chat/completions

`POST /chat/completions`

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

## Request body

- object
  - `reqPayload` object — DEPRECATED. Use the top-level fields instead
    - `model` string, required
    - `messages` union[], required
      - union
        - object
          - `role` 'system', required
          - `content` string
        - object
          - `role` 'user', required
          - `content` union
            - string
            - union[]
              - …
        - object
          - `role` 'assistant', required
          - `content` union
            - string
            - 'null', nullable
          - `function_call` object
            - `name` string
            - `arguments` string
          - `tool_calls` object[]
            - `id` string, required
            - `function` object, required
              - …
            - `type` 'function', required
        - object
          - `role` 'tool', required
          - `content` string
          - `tool_call_id` string, required
        - object
          - `role` 'function', required
          - `name` string, required
          - `content` union, required
            - string
            - 'null', nullable
    - `function_call` union
      - 'none'
      - 'auto'
      - object
        - `name` string, required
    - `functions` object[]
      - `name` string, required
      - `parameters` object
      - `description` string
    - `tool_choice` union
      - 'none'
      - 'auto'
      - object
        - `type` 'function'
        - `function` object
          - `name` string, required
    - `tools` object[]
      - `function` object, required
        - `name` string, required
        - `parameters` object
        - `description` string
      - `type` 'function', required
    - `n` number
    - `max_tokens` number, nullable
    - `temperature` number
    - `response_format` object
      - `type` union, required
        - 'text'
        - 'json_object'
    - `stream` boolean
  - `model` string
  - `messages` union[]
    - union
      - object
        - `role` 'system', required
        - `content` string
      - object
        - `role` 'user', required
        - `content` union
          - string
          - union[]
            - union
              - …
      - object
        - `role` 'assistant', required
        - `content` union
          - string
          - 'null', nullable
        - `function_call` object
          - `name` string
          - `arguments` string
        - `tool_calls` object[]
          - `id` string, required
          - `function` object, required
            - `name` string, required
            - `arguments` string, required
          - `type` 'function', required
      - object
        - `role` 'tool', required
        - `content` string
        - `tool_call_id` string, required
      - object
        - `role` 'function', required
        - `name` string, required
        - `content` union, required
          - string
          - 'null', nullable
  - `function_call` union
    - 'none'
    - 'auto'
    - object
      - `name` string, required
  - `functions` object[]
    - `name` string, required
    - `parameters` object
    - `description` string
  - `tool_choice` union
    - 'none'
    - 'auto'
    - object
      - `type` 'function'
      - `function` object
        - `name` string, required
  - `tools` object[]
    - `function` object, required
      - `name` string, required
      - `parameters` object
      - `description` string
    - `type` 'function', required
  - `n` number, nullable
  - `max_tokens` number, nullable
  - `temperature` number, nullable
  - `stream` boolean
  - `response_format` object
    - `type` union
      - 'text'
      - 'json_object'

## Response `200`

Successful response

- union
  - object, nullable
    - `id` string, required
    - `object` 'chat.completion', required
    - `created` number, required
    - `model` string, required
    - `choices` object[], required
      - `finish_reason` union, required
        - 'length'
        - 'function_call'
        - 'tool_calls'
        - 'stop'
        - 'content_filter'
      - `index` number, required
      - `message` object, required
        - `role` 'assistant', required
        - `content` union
          - string
          - 'null', nullable
        - `function_call` object
          - `name` string
          - `arguments` string
        - `tool_calls` object[]
          - `id` string, required
          - `function` object, required
            - `name` string, required
            - `arguments` string, required
          - `type` 'function', required
      - `logprobs` object, nullable
        - `content` object[], nullable, required
          - `token` string, required
          - `bytes` number[], nullable, required
          - `logprob` number, required
          - `top_logprobs` object[], required
            - `token` string, required
            - `bytes` number[], nullable, required
            - `logprob` number, required
    - `usage` object
      - `prompt_tokens` number, required
      - `completion_tokens` number, required
      - `total_tokens` number, required
  - unknown

## Other responses

- `default` — Error response

---

[API](https://skmtc.net/openpipe/apis/openpipe-api.md) · [All operations](https://skmtc.net/openpipe/apis/openpipe-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/openpipe/openpipe-api/versions/4054c6b918a8/schema)
