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"