# 快速入门指南

本指南将带你了解从注册账号到发起第一个 API 请求并监控用量的完整流程。

## 1. 注册账号并登录控制台

1. 访问 [Tokenlio 控制台](https://api.tokenlio.ai/register)
2. 填写邮箱完成注册并登录
3. 登录后即可进入你的默认个人或团队工作空间 (Workspace)

## 2. 充值账户余额

Tokenlio 采用充值预付、按量扣费的计费方式：
- 充值随用随走，最低充值仅需 $10 USD
- 支持支付宝、微信支付与主流国际卡渠道
- 余额变动实时可查，提供清晰的账单对账流水

## 3. 创建 API 密钥

在发起 API 调用之前，需要在控制台中生成专属 API Key：
1. 点击左侧导航栏中的 **API 密钥 (API Keys)**
2. 点击 **创建密钥 (Create Key)**
3. 复制生成的明文密钥（例如 `tk-xxxxxxxxxxxxxxxxxxxx`）。**注意：明文仅展示一次，请妥善保存至环境变量中**

## 4. 发起第一次请求

Tokenlio 端点与 OpenAI 官方规范完全兼容。只需将 `base_url` 指向 `https://api.tokenlio.ai`：

### Python 示例

```python
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ.get("TOKENLIO_API_KEY", "tk-your-api-key"),
    base_url="https://api.tokenlio.ai/v1"
)

response = client.chat.completions.create(
    model="gpt-4-turbo",
    messages=[
        {"role": "system", "content": "你是一位优秀的技术助手。"},
        {"role": "user", "content": "请用一句话介绍 Tokenlio 平台的优势。"}
    ]
)

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

### Node.js 示例

```javascript
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env.TOKENLIO_API_KEY,
  baseURL: 'https://api.tokenlio.ai/v1'
});

const response = await client.chat.completions.create({
  model: 'claude-3-5-sonnet',
  messages: [{ role: 'user', content: '你好，世界！' }],
});

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

### cURL 示例

```bash
curl https://api.tokenlio.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer tk-your-api-key" \
  -d '{
    "model": "deepseek-chat",
    "messages": [{"role": "user", "content": "你好！"}]
  }'
```

## 下一步

- 了解 [流式响应 (Streaming)](/zh/guide/streaming) 的处理方法
- 查阅 [错误码规范与重试机制](/zh/guide/error-handling)
- 在 [模型广场](https://api.tokenlio.ai/marketplace) 中挑选适合业务的旗舰模型
