> ## Documentation Index
> Fetch the complete documentation index at: https://docs.arouter.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# cURL

> cURL でクイックテストとスクリプティング。

## OpenAI 互換エンドポイント

```bash theme={null}
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!"}]
  }'
```

### プロバイダーの切り替え

```bash theme={null}
# 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!"}]
  }'
```

### ストリーミング

```bash theme={null}
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
  }'
```

<Tip>
  `-N` フラグは出力バッファリングを無効にし、token がリアルタイムで表示されます。
</Tip>

## Anthropic ネイティブエンドポイント

```bash theme={null}
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 ネイティブエンドポイント

```bash theme={null}
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!"}]}]
  }'
```

## モデル一覧

```bash theme={null}
curl https://api.arouter.ai/v1/models \
  -H "Authorization: Bearer lr_live_xxxx"
```

## エンベディング

```bash theme={null}
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 の作成

```bash theme={null}
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 の一覧

```bash theme={null}
curl https://api.arouter.ai/api/v1/keys \
  -H "Authorization: Bearer lr_mgmt_xxxx"
```

### API Key の更新

```bash theme={null}
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 の削除

```bash theme={null}
curl -X DELETE https://api.arouter.ai/api/v1/keys/KEY_HASH \
  -H "Authorization: Bearer lr_mgmt_xxxx"
```
