Chat Completions
OpenAI-compatible chat completions endpoint.
POST
/v1/chat/completionsRequest Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | The model to use for completion (e.g. "gpt-4o", "claude-sonnet-4-20250514") |
messages | array | Yes | Array of message objects with role (system/user/assistant) and content |
max_tokens | integer | No | Maximum number of tokens to generate. Defaults to model max. |
temperature | number | No | Sampling temperature between 0 and 2. Higher = more creative. Default: 1 |
top_p | number | No | Nucleus sampling. Considers tokens with top_p probability mass. Default: 1 |
stream | boolean | No | If true, returns a stream of server-sent events. Default: false |
Response Format
Non-streaming responses return a complete JSON object:
Response
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1712678400,
"model": "gpt-4o",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I help you today?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 9,
"total_tokens": 21
}
}Streaming
When stream: true, the response is delivered as Server-Sent Events (SSE). Each event contains a chunk of the completion:
SSE stream format
data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","created":1712678400,"model":"gpt-4o","choices":[{"index":0,"delta":{"role":"assistant"},"finish_reason":null}]}
data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","created":1712678400,"model":"gpt-4o","choices":[{"index":0,"delta":{"content":"Hello"},"finish_reason":null}]}
data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","created":1712678400,"model":"gpt-4o","choices":[{"index":0,"delta":{"content":"!"},"finish_reason":null}]}
data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","created":1712678400,"model":"gpt-4o","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}
data: [DONE]The stream ends with a data: [DONE] event.
Streaming Example
curl https://api.osiris.ai/v1/chat/completions \
-H "Authorization: Bearer sk-osiris-YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"stream": true,
"messages": [{"role": "user", "content": "Hello!"}]
}'