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

> Quick testing and scripting with cURL.

## OpenAI-Compatible Endpoint

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

### Switch Provider

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

### Streaming

```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": "Write a poem."}],
    "stream": true
  }'
```

<Tip>
  The `-N` flag disables output buffering so you see tokens as they arrive.
</Tip>

## Anthropic Native Endpoint

```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 Native Endpoint

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

## List Models

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

## Embeddings

```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 Management

Use a management key (`lr_mgmt_`) to manage API keys.

### Create 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"
  }'
```

### List API Keys

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

### Update 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}'
```

### Delete API Key

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