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

# API 参考

> EzTokens API 端点、鉴权和请求格式说明

EzTokens API 完全兼容 OpenAI 接口格式。所有请求发送至统一的 Base URL。

## Base URL

```text theme={null}
https://api.eztokens.ai
```

## 鉴权

所有 API 请求需要在 HTTP Header 中携带 API 密钥：

```text theme={null}
Authorization: Bearer $EZTOKENS_API_KEY
```

## 主要端点

| 端点                       | 说明              |
| ------------------------ | --------------- |
| `POST /chat/completions` | 对话补全，支持文本、图片、视频 |
| `GET /models`            | 获取可用模型列表        |
| `POST /chat/task/status` | 查询异步任务状态（视频生成等） |

## 模型 ID 格式

模型使用官方名称标识，例如：

* `deepseek-v4-pro`
* `claude-sonnet-4-6`
* `glm-5.2`
* `gpt-5.4`
* `gpt-image-2`

<Note>
  完整的模型列表请在控制台模型库中查看，或通过 `GET /models` 接口获取。
</Note>

## Embeddings

文本向量化，将文本转为高维向量，用于语义搜索、聚类和相似度计算：

```bash theme={null}
curl https://api.eztokens.ai/v1/embeddings \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $EZTOKENS_API_KEY" \
  -d '{"model": "text-embedding-3-small", "input": "Your text here"}'
```

```python theme={null}
response = client.embeddings.create(
    model="text-embedding-3-small",
    input=["文本1", "文本2", "文本3"]
)
# response.data[0].embedding → 向量列表
```

## 文本审核（Moderation）

检测文本中的敏感内容：

```bash theme={null}
curl https://api.eztokens.ai/v1/moderations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $EZTOKENS_API_KEY" \
  -d '{"input": "Text to moderate."}'
```

```python theme={null}
response = client.moderations.create(input="Text to check.")
print(response.results[0].flagged)       # 是否违规
print(response.results[0].category_scores)  # 各类别分数
```
