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

# Quickstart: API Key & First Call

> Get your XRoute API key, make your first model call (text, image, video), and monitor usage in minutes.

Welcome to XRoute. Follow this quickstart guide to obtain your unified API key, send your first model request across unified OpenAI, Anthropic, or native multimodal endpoints, and monitor your usage in real time.

**1. Obtain your API Key**

In the left sidebar of the personal console, click **Access Credentials** (`https://xroute.ai/personal/keys`).

XRoute provides a `default` credential key out-of-the-box. Click the **Copy** icon next to the API Key input field to copy your secret key (`sk-...`).

![Access Credentials Overview](https://mintcdn.com/aaa-fac9ff58/ZSwjhSxfbQOFBUl0/images/quickstart/api-keys-overview.png?fit=max\&auto=format\&n=ZSwjhSxfbQOFBUl0\&q=85\&s=20405634c7a2027f43a1087be0067aa5)

Access credentials overview showing the default API Key and copy button

**2. (Optional) Create a new API key**

To isolate environments or control access permissions across different applications, you can create additional keys:

1. Click the **+ Create** button at the top of the credentials list.
2. Enter a descriptive **Name** for your key (e.g. `dev-agent` or `production`).
3. Choose the authentication type (**API Key**), parameter location (`Header: Authorization`), and optional expiration date.
4. Click **Confirm** to generate the key.

![Create New Access Key](https://mintcdn.com/aaa-fac9ff58/ZSwjhSxfbQOFBUl0/images/quickstart/create-api-key-modal.png?fit=max\&auto=format\&n=ZSwjhSxfbQOFBUl0\&q=85\&s=72768657b5b01df98652b7bdb624fc6f)

Dialog for creating a new access credential

**3. Quickest call: Copy pre-configured cURL from Dashboard**

You do not need to manually assemble endpoint URLs, model identifiers, or headers. The XRoute **Personal Dashboard** provides a **Quick Call Guide** that automatically generates ready-to-run code with your secret key and chosen model pre-filled:

1. In the left navigation menu, click **Dashboard** (`https://xroute.ai/personal/dashboard`).
2. Under **Quick Call Guide**, choose your target **AI Model** and **Credential** (e.g. `default`).
3. Select your protocol format (**OpenAI Compatible Format**, **Claude Compatible Format**, or **Native Invocation Mode**).
4. Click **Copy Code** on the **CURL** tab, paste it into your terminal, and run it immediately!

![Dashboard Quick Call Guide](https://mintcdn.com/aaa-fac9ff58/ZSwjhSxfbQOFBUl0/images/quickstart/dashboard-quick-call.png?fit=max\&auto=format\&n=ZSwjhSxfbQOFBUl0\&q=85\&s=e9970aad5cd4a58e1dbdd40958a76d2f)

XRoute Personal Dashboard Quick Call Guide with ready-to-copy cURL command

**4. Export your API key in your environment**

For programmatic usage with SDKs or command-line scripts, export the API key in your terminal session:

```bash theme={null}
export XROUTE_API_KEY="sk_your_key_here"
```

> [!WARNING]
>
> Never commit your API keys to public repositories or expose them in client-side frontend code.

**5. Send your first request**

XRoute supports multiple generation modalities and protocols. Choose the format that fits your application:

> [!NOTE]
>
> * **Text Models**: Support **OpenAI Unified** (`https://api.xroute.ai/v1/chat/completions`), **Anthropic Unified** (`https://api.xroute.ai/v1/messages`), and **Provider Native** formats.
> * **Image Models**: Call provider native endpoints directly (e.g. `https://api.xroute.ai/OpenAI/images/generations`).
> * **Video Models**: Asynchronous workflow (submit task to `/contents/generations/tasks`, then poll status).

```bash cURL (OpenAI Format) theme={null}
curl -X POST "https://api.xroute.ai/v1/chat/completions" \
  -H "Authorization: Bearer $XROUTE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "OpenAI/gpt-6-astra",
    "messages": [
      {"role": "user", "content": "Hello! Explain why XRoute is useful in 2 sentences."}
    ]
  }'
```

```python Python (OpenAI SDK) theme={null}
from openai import OpenAI
import os

client = OpenAI(
    base_url="https://api.xroute.ai/v1",
    api_key=os.environ.get("XROUTE_API_KEY"),
)

response = client.chat.completions.create(
    model="OpenAI/gpt-6-astra",
    messages=[
        {"role": "user", "content": "Hello! Explain why XRoute is useful in 2 sentences."}
    ],
)

print(response.choices[0].message.content)
```

```javascript Node.js (OpenAI SDK) theme={null}
import OpenAI from "openai";

const openai = new OpenAI({
  baseURL: "https://api.xroute.ai/v1",
  apiKey: process.env.XROUTE_API_KEY,
});

const completion = await openai.chat.completions.create({
  model: "OpenAI/gpt-6-astra",
  messages: [
    { role: "user", content: "Hello! Explain why XRoute is useful in 2 sentences." },
  ],
});

console.log(completion.choices[0].message.content);
```

```bash cURL (Anthropic Messages) theme={null}
curl -X POST "https://api.xroute.ai/v1/messages" \
  -H "x-api-key: $XROUTE_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "Anthropic/claude-fable-5",
    "max_tokens": 1024,
    "messages": [
      {"role": "user", "content": "What makes a reliable API gateway?"}
    ]
  }'
```

```bash cURL (Image Generation) theme={null}
curl -X POST "https://api.xroute.ai/OpenAI/images/generations" \
  -H "Authorization: Bearer $XROUTE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-2.5-flare",
    "prompt": "An ultra-modern data center glowing in cyberpunk neon lights, 8k resolution",
    "size": "1024x1024"
  }'
```

```bash cURL (Video Generation Async) theme={null}
# 1. Submit video generation task
curl -X POST "https://api.xroute.ai/Byteplus/contents/generations/tasks" \
  -H "Authorization: Bearer $XROUTE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "seedance-1-5-pro-251215",
    "content": [
      {"type": "text", "text": "A drone flying through a sunset canyon, cinematic lighting"}
    ]
  }'

# 2. Query task status with returned task_id
# curl -X GET "https://api.xroute.ai/Byteplus/contents/generations/tasks/{task_id}" \
#   -H "Authorization: Bearer $XROUTE_API_KEY"
```

**6. Check balance and call statistics**

After making requests, you can monitor your account usage and API traffic directly in the console:

1. **View balance and today's usage on the Dashboard**: Go to **Dashboard** (`https://xroute.ai/personal/dashboard`) to view your real-time **Account Balance (USD)**, **Today's Usage**, and total **Today's Calls**.

![Personal Dashboard Overview](https://mintcdn.com/aaa-fac9ff58/ZSwjhSxfbQOFBUl0/images/quickstart/dashboard-overview.png?fit=max\&auto=format\&n=ZSwjhSxfbQOFBUl0\&q=85\&s=9f3728228c47060648e5cc6869ea5d24)

Check your account balance and today's usage in the Personal Dashboard

2. **Inspect detailed invocation metrics in Call Statistics**: Under **REPORTS** in the left sidebar, click **Call Statistics** (`https://xroute.ai/personal/call`) to analyze your model calls. You can view **Total Calls**, **Success Call Rate**, **Average Duration**, **Total Tokens Called**, **Total Consumption Amount**, and the real-time **Model Invocation Trend** breakdown chart.

![Call Statistics Analysis](https://mintcdn.com/aaa-fac9ff58/ZSwjhSxfbQOFBUl0/images/quickstart/call-statistics.png?fit=max\&auto=format\&n=ZSwjhSxfbQOFBUl0\&q=85\&s=0ef6c119bf4f3510de549c6f6191fb9e)

Monitor model traffic, token consumption, and duration in Call Statistics

***

## Next steps

> [card] [SDK Compatibility](https://docs.xroute.ai/get-started/sdk-compatibility.md)
>
> Use XRoute with OpenAI, Anthropic, LangChain, LlamaIndex, or Byteplus SDKs.

> [card] [Model Catalog](https://docs.xroute.ai/resources/models/overview.md)
>
> Explore all supported LLMs, image generation, and video generation models.

> [card] [XRoute Console](https://docs.xroute.ai/console/overview.md)
>
> Manage access credentials, monitor real-time balance, configure model mapping failovers, and track call statistics.

> [card] [Rate Limits & Errors](https://docs.xroute.ai/api-reference/rate-limits)
>
> Understand default rate limits, retry mechanisms, and error codes.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.