# Chat Completions API > POST /v1/chat/completions — the OpenAI-format endpoint, for Cursor, LangChain, LiteLLM and the OpenAI SDKs. _Source: https://aiprimetech.io/docs/api-reference/chat-completions/ · Home > Docs > API reference_ The OpenAI-compatible surface. Same models, same prices, different envelope. - **Endpoint:** `POST https://aiprimetech.io/v1/chat/completions` - **Base URL for SDKs:** `https://aiprimetech.io/v1` — note the /v1 - **Auth:** `Authorization: Bearer sk-...` ## Request body | Field | Type | Required | Description | |---|---|---|---| | `model` | string | yes | Any id from `/v1/models`, including Claude ids | | `messages` | array | yes | Supports system, user and assistant roles | | `max_tokens` | integer | no | Optional here, unlike the Messages API | | `temperature` | number | no | 0–2 in the OpenAI convention | | `stream` | boolean | no | true for SSE chunks | | `tools` | array | no | OpenAI function-calling shape | > Unlike Messages, `system` **is** a role here — put it as the first entry of `messages`. Do not send a top-level `system` field to this endpoint. ## Example ```bash curl https://aiprimetech.io/v1/chat/completions \ -H "Authorization: Bearer $CLAUDEAPIKEY" \ -H "content-type: application/json" \ -d '{ "model": "claude-sonnet-4-6", "messages": [{"role": "user", "content": "Hello"}] }' ``` ## Response ```json { "id": "chatcmpl-...", "object": "chat.completion", "model": "claude-sonnet-4-6", "choices": [{ "index": 0, "message": {"role": "assistant", "content": "..."}, "finish_reason": "stop" }], "usage": {"prompt_tokens": 9, "completion_tokens": 12, "total_tokens": 21} } ``` ## Using the OpenAI SDK ```python from openai import OpenAI client = OpenAI( api_key="sk-your-key", base_url="https://aiprimetech.io/v1", # the /v1 matters ) resp = client.chat.completions.create( model="claude-sonnet-4-6", messages=[{"role": "user", "content": "Hello"}], ) print(resp.choices[0].message.content) ``` ## Field mapping between the two formats | Concept | Messages | Chat Completions | |---|---|---| | System prompt | top-level `system` | `messages[0]` with role system | | Reply text | `content[0].text` | `choices[0].message.content` | | Why it stopped | `stop_reason` | `finish_reason` | | Input tokens | `usage.input_tokens` | `usage.prompt_tokens` | | Output tokens | `usage.output_tokens` | `usage.completion_tokens` | | Stream delta | `content_block_delta` | `choices[0].delta.content` | - [Cursor](https://aiprimetech.io/docs/guides/cursor/) — Configure Cursor against this endpoint - [Migrating from OpenAI](https://aiprimetech.io/docs/guides/migration-from-openai/) — Switch an existing codebase - [Streaming](https://aiprimetech.io/docs/api-reference/streaming/) — SSE for both formats --- _ClaudeAPIKey.dev is an independently operated, Anthropic-compatible API gateway. Not affiliated with Anthropic._