API Usage
Auto AI Router exposes an OpenAI-compatible API. Any client that works with the OpenAI API can be pointed at the router.
Chat Completions
curl -X POST http://localhost:8080/v1/chat/completions \
-H "Authorization: Bearer sk-your-master-key-here" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"messages": [{"role": "user", "content": "Hello!"}]
}'
Streaming
Add "stream": true to enable Server-Sent Events streaming:
curl -X POST http://localhost:8080/v1/chat/completions \
-H "Authorization: Bearer sk-your-master-key-here" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"messages": [{"role": "user", "content": "Hello!"}],
"stream": true
}'
Using with OpenAI SDK
from openai import OpenAI
client = OpenAI(
base_url="http://localhost:8080/v1",
api_key="sk-your-master-key-here",
)
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)
Responses API
The router supports the OpenAI Responses API with native provider integration for Anthropic, Vertex AI, and AWS Bedrock.
curl -X POST http://localhost:8080/v1/responses \
-H "Authorization: Bearer sk-your-master-key-here" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-20250514",
"input": "Hello!"
}'
Streaming
curl -X POST http://localhost:8080/v1/responses \
-H "Authorization: Bearer sk-your-master-key-here" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-20250514",
"input": "Hello!",
"stream": true
}'
WebSocket
Connect to ws://localhost:8080/v1/responses (with Upgrade: websocket) for persistent multi-turn sessions. See Responses API — WebSocket for the full protocol.
Compact
curl -X POST http://localhost:8080/v1/responses/compact \
-H "Authorization: Bearer sk-your-master-key-here" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-20250514",
"input": "..."
}'
Using with OpenAI SDK
from openai import OpenAI
client = OpenAI(
base_url="http://localhost:8080/v1",
api_key="sk-your-master-key-here",
)
response = client.responses.create(
model="claude-sonnet-4-20250514",
input="Hello!",
)
print(response.output_text)
Health Check
See Health Endpoints for details on the response format.
Authentication
All API requests require the Authorization header with the master key:
Health endpoints (/health, /vhealth, /metrics) do not require authentication.