OpenAI 相容端點
curl https://api.arouter.ai/v1/chat/completions \
-H "Authorization: Bearer lr_live_xxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-5.4",
"messages": [{"role": "user", "content": "Hello!"}]
}'
切換 Provider
# 透過 OpenAI 相容端點使用 Anthropic
curl https://api.arouter.ai/v1/chat/completions \
-H "Authorization: Bearer lr_live_xxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "anthropic/claude-sonnet-4.6",
"messages": [{"role": "user", "content": "Hello!"}]
}'
串流輸出
curl https://api.arouter.ai/v1/chat/completions \
-H "Authorization: Bearer lr_live_xxxx" \
-H "Content-Type: application/json" \
-N \
-d '{
"model": "openai/gpt-5.4",
"messages": [{"role": "user", "content": "寫一首詩。"}],
"stream": true
}'
-N 旗標可停用輸出緩衝,讓您即時看到生成的 token。
Anthropic 原生端點
curl https://api.arouter.ai/v1/messages \
-H "X-Api-Key: lr_live_xxxx" \
-H "Content-Type: application/json" \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": "claude-sonnet-4.6",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Hello!"}]
}'
Gemini 原生端點
curl "https://api.arouter.ai/v1beta/models/gemini-2.5-flash:generateContent?key=lr_live_xxxx" \
-H "Content-Type: application/json" \
-d '{
"contents": [{"parts": [{"text": "Hello!"}]}]
}'
列出模型
curl https://api.arouter.ai/v1/models \
-H "Authorization: Bearer lr_live_xxxx"
嵌入向量
curl https://api.arouter.ai/v1/embeddings \
-H "Authorization: Bearer lr_live_xxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/text-embedding-3-small",
"input": "The quick brown fox"
}'
Key 管理
使用管理密鑰(lr_mgmt_)管理 API key。
建立 API Key
curl -X POST https://api.arouter.ai/api/v1/keys \
-H "Authorization: Bearer lr_mgmt_xxxx" \
-H "Content-Type: application/json" \
-d '{
"name": "backend-service",
"allowed_providers": ["openai", "anthropic"],
"limit": 150,
"limit_reset": "monthly"
}'
列出 API Key
curl https://api.arouter.ai/api/v1/keys \
-H "Authorization: Bearer lr_mgmt_xxxx"
更新 API Key
curl -X PATCH https://api.arouter.ai/api/v1/keys/KEY_HASH \
-H "Authorization: Bearer lr_mgmt_xxxx" \
-H "Content-Type: application/json" \
-d '{"disabled": true}'
刪除 API Key
curl -X DELETE https://api.arouter.ai/api/v1/keys/KEY_HASH \
-H "Authorization: Bearer lr_mgmt_xxxx"