---
title: "Create a chat completion"
method: POST
path: "/v1/chat/completions"
---

# Create a chat completion

`POST /v1/chat/completions`

## Request

- Base URL: `https://infer.flow7.org`
- URL: `https://infer.flow7.org/v1/chat/completions`
- Auth: HTTP bearer

OpenAI Chat Completions-compatible skin over the same Infer routing, wallet, privacy, cache, media, tool, and receipt engine used by /v1/responses. With stream=true, chat.completion.chunk events carry upstream reasoning, text, and tool-call argument deltas as they arrive; the final finish chunk includes relay receipt metadata and stream_options.include_usage adds the settled usage chunk. Infer emits keepalive comments during quiet periods and does not impose a generation wall-clock timeout while the connection remains alive.

## Headers

- `Idempotency-Key` string
- `X-Session-Affinity` string

## Request body

- ChatCompletionRequest: OpenAI Chat Completions compatibility request. Infer normalizes this into the same canonical request used by /v1/responses; n values other than 1, audio output, prediction, web_search_options, and returned logprobs are not currently supported.
  - `model` string, required
  - `messages` ChatMessage[], required
    - `role` 'system' | 'developer' | 'user' | 'assistant' | 'tool' | 'function', required
    - `content` unknown
    - `name` string
    - `tool_call_id` string
    - `tool_calls` object[]
    - `function_call` object
  - `max_completion_tokens` integer: Requested output ceiling. Capacity is limited by the selected Infer model/price option and its eligible routes, not by a global Infer token cap.
  - `max_tokens` integer: Requested output ceiling. Capacity is limited by the selected Infer model/price option and its eligible routes, not by a global Infer token cap.
  - `stream` boolean
  - `stream_options` object
  - `temperature` number
  - `top_p` number
  - `presence_penalty` number
  - `frequency_penalty` number
  - `seed` integer
  - `stop` unknown
  - `tools` object[]
  - `tool_choice` unknown
  - `parallel_tool_calls` boolean
  - `response_format` object
  - `store` boolean
  - `prompt_cache_key` string
  - `cache_control` object
  - `relay` RelayRequestOptions
    - `session_id` string
    - `privacy` 'standard' | 'no-training' | 'zero-retention'

## Response `200`

Chat completion or SSE stream

- ChatCompletionResponse
  - `id` string, required
  - `object` 'chat.completion', required
  - `created` integer, required
  - `model` string, required
  - `choices` object[], required
  - `usage` object, required
  - `relay` RelayResponseMetadata, required
    - `receipt_id` string, required
    - `price_version` string, required: Opaque reference (pv_…) to the immutable price version that priced this request. It matches the catalog option and the usage receipt and reveals no supplier or cost information.
    - `tier` 'low-cost' | 'balanced' | 'stable' | 'official', required
    - `resolved_model_class` string, required
    - `cache_status` 'hit' | 'partial' | 'miss', required
    - `environment` 'live', required
    - `provider_disclosed` false, required
    - `customer_cost_usd` number, required
    - `idempotent_replay` boolean

## Other responses

- `400`: Error
- `401`: Error
- `403`: Error
- `413`: Error
- `422`: Error
- `429`: Error
- `500`: Error
- `503`: Error

---

[API](https://skmtc.dev/flow7/apis/infer-by-flow7-public-api.md) · [All operations](https://skmtc.dev/flow7/apis/infer-by-flow7-public-api/llms.txt) · [OpenAPI document](https://skmtc.dev/flow7/apis/infer-by-flow7-public-api/revisions/e73ecffd3cf3?raw)
