メインコンテンツへスキップ

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!"}]
  }'

プロバイダーの切り替え

# 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"