Unified Mode

cURL (Unified Mode)

Raw HTTP examples for the unified endpoint

The unified endpoint is POST /v1/chat/completions. It accepts an OpenAI-compatible request body and returns an OpenAI-compatible response, regardless of which provider handles the request.

Basic request

$curl -X POST https://gateway.example.com/v1/chat/completions \
> -H "Authorization: Bearer sk-proxy-YOUR_KEY_HERE" \
> -H "Content-Type: application/json" \
> -d '{
> "model": "openai/gpt-4o",
> "messages": [
> {"role": "user", "content": "Hello!"}
> ]
> }'

Calling Anthropic

$curl -X POST https://gateway.example.com/v1/chat/completions \
> -H "Authorization: Bearer sk-proxy-YOUR_KEY_HERE" \
> -H "Content-Type: application/json" \
> -d '{
> "model": "anthropic/claude-sonnet-4-6",
> "messages": [
> {"role": "system", "content": "You are a helpful assistant."},
> {"role": "user", "content": "What is quantum computing?"}
> ],
> "max_tokens": 512
> }'

Calling Gemini

$curl -X POST https://gateway.example.com/v1/chat/completions \
> -H "Authorization: Bearer sk-proxy-YOUR_KEY_HERE" \
> -H "Content-Type: application/json" \
> -d '{
> "model": "google/gemini-2.5-flash",
> "messages": [
> {"role": "user", "content": "Write a haiku about APIs."}
> ]
> }'

Streaming

Add "stream": true to get Server-Sent Events:

$curl -X POST https://gateway.example.com/v1/chat/completions \
> -H "Authorization: Bearer sk-proxy-YOUR_KEY_HERE" \
> -H "Content-Type: application/json" \
> -N \
> -d '{
> "model": "anthropic/claude-sonnet-4-6",
> "messages": [
> {"role": "user", "content": "Write a short story."}
> ],
> "stream": true
> }'

The response is a stream of data: lines in OpenAI’s SSE format:

data: {"id":"chatcmpl-...","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"Once"},"finish_reason":null}]}
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":" upon"},"finish_reason":null}]}
...
data: [DONE]

Tool calling

$curl -X POST https://gateway.example.com/v1/chat/completions \
> -H "Authorization: Bearer sk-proxy-YOUR_KEY_HERE" \
> -H "Content-Type: application/json" \
> -d '{
> "model": "openai/gpt-4o",
> "messages": [
> {"role": "user", "content": "What is the weather in Tokyo?"}
> ],
> "tools": [
> {
> "type": "function",
> "function": {
> "name": "get_weather",
> "description": "Get weather for a city",
> "parameters": {
> "type": "object",
> "properties": {
> "city": {"type": "string"}
> },
> "required": ["city"]
> }
> }
> }
> ],
> "tool_choice": "auto"
> }'

Response format

All responses follow the OpenAI chat completion format:

1{
2 "id": "chatcmpl-abc123",
3 "object": "chat.completion",
4 "model": "anthropic/claude-sonnet-4-6",
5 "choices": [
6 {
7 "index": 0,
8 "message": {
9 "role": "assistant",
10 "content": "Hello! How can I help you today?"
11 },
12 "finish_reason": "stop"
13 }
14 ],
15 "usage": {
16 "prompt_tokens": 12,
17 "completion_tokens": 9,
18 "total_tokens": 21
19 }
20}

The model field in the response reflects the provider and model that handled the request (e.g., anthropic/claude-sonnet-4-6 or google/gemini-2.5-flash).