For AI agents, the documentation index lists all pages. Append .md to a documentation URL for Markdown, or request text/markdown.

Skip to Content
spare inference

Create a chat completion

OpenAI Chat Completions format, streaming included.

1 min readEdit this page
POST
/v1/chat/completions

OpenAI Chat Completions format. Send stream: true for Server-Sent Events, ending with data: [DONE]. The x-bitrouter-request-id response header identifies the request for settlement.

Authorization

x-api-key<token>

x-api-key: <key>. Anthropic SDKs send this.

In: header

Request Body

application/json

Chat completion request.

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "https://example.com/v1/chat/completions" \  -H "Content-Type: application/json" \  -d '{    "messages": [      {        "role": "string"      }    ],    "model": "string"  }'
{  "choices": [    {      "finish_reason": "string",      "index": 0,      "message": {        "content": "string",        "role": "string"      }    }  ],  "created": 0,  "id": "string",  "model": "string",  "object": "string",  "usage": {    "completion_tokens": 0,    "prompt_tokens": 0,    "total_tokens": 0  }}

How is this guide?