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

# AIsa CN-LLM Route

> 通过 AIsa 将中文提示路由到中文 LLM 家族。

[在 GitHub 上查看 ->](https://github.com/AIsa-team/agent-skills/tree/main/cn-llm)

**通过 AIsa 进行中文 LLM 路由。** 将中文任务发送到 Qwen、DeepSeek、GLM、Baichuan 及相关模型家族。

## 安装

如果还没有安装 AIsa CLI，请先安装：

```bash theme={null}
npm install -g @aisa-one/cli
```

然后安装该技能：

```bash theme={null}
aisa skills install cn-llm
```

## Agent 可以用它做什么？

<CardGroup cols={2}>
  <Card title="中文提示" icon="language">
    将中文任务路由到强大的中文 LLM。
  </Card>

  <Card title="模型选择" icon="list">
    在 Qwen、DeepSeek、GLM、Baichuan 及相关模型间选择。
  </Card>

  <Card title="双语工作流" icon="arrows-left-right">
    在中文模型和全球模型家族之间切换。
  </Card>

  <Card title="Agent 默认策略" icon="sliders">
    为 Agent 提供实用的路由启发式规则。
  </Card>
</CardGroup>

## 🔥 可以做什么

### 智能聊天

```
"Use Qwen to answer Chinese questions, use DeepSeek for coding"
```

### 深度推理

```
"Use DeepSeek-R1 for complex reasoning tasks"
```

### 代码生成

```
"Use DeepSeek-Coder to generate Python code with explanations"
```

### 长文本处理

```
"Use Qwen-Long for ultra-long document summarization"
```

### 模型对比

```
"Compare response quality between Qwen-Max and DeepSeek-V3"
```

## 支持的模型

### Qwen（阿里巴巴）

| 模型                             | 输入价格      | 输出价格      | 特性        |
| ------------------------------ | --------- | --------- | --------- |
| qwen3-max                      | \$1.37/M  | \$5.48/M  | 最强通用模型    |
| qwen3-max-2026-01-23           | \$1.37/M  | \$5.48/M  | 最新版本      |
| qwen3-coder-plus               | \$2.86/M  | \$28.60/M | 增强代码生成    |
| qwen3-coder-flash              | \$0.72/M  | \$3.60/M  | 快速代码生成    |
| qwen3-coder-480b-a35b-instruct | \$2.15/M  | \$8.60/M  | 480B 大模型  |
| qwen3-vl-plus                  | \$0.43/M  | \$4.30/M  | 视觉语言模型    |
| qwen3-vl-flash                 | \$0.86/M  | \$0.86/M  | 快速视觉模型    |
| qwen3-omni-flash               | \$4.00/M  | \$16.00/M | 多模态模型     |
| qwen-vl-max                    | \$0.23/M  | \$0.57/M  | 视觉语言      |
| qwen-plus-2025-12-01           | \$1.26/M  | \$12.60/M | Plus 版本   |
| qwen-mt-flash                  | \$0.168/M | \$0.514/M | 快速机器翻译    |
| qwen-mt-lite                   | \$0.13/M  | \$0.39/M  | Lite 机器翻译 |

### DeepSeek

| 模型               | 输入价格     | 输出价格      | 特性             |
| ---------------- | -------- | --------- | -------------- |
| deepseek-r1      | \$2.00/M | \$8.00/M  | 推理模型，支持 Tools  |
| deepseek-v3      | \$1.00/M | \$4.00/M  | 通用聊天，671B 参数   |
| deepseek-v3-0324 | \$1.20/M | \$4.80/M  | V3 稳定版本        |
| deepseek-v3.1    | \$4.00/M | \$12.00/M | 最新 Terminus 版本 |

> **注意**：价格中的 M 表示 million tokens。模型可用性可能变化，请查看 [console.aisa.one/pricing](https://console.aisa.one/pricing) 获取最新列表。

## 快速开始

```bash theme={null}
export AISA_API_KEY="your-key"
```

## API 端点

### OpenAI 兼容接口

```
POST https://api.aisa.one/v1/chat/completions
```

#### Qwen 示例

```bash theme={null}
curl -X POST "https://api.aisa.one/v1/chat/completions" \
  -H "Authorization: Bearer ***" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen3-max",
    "messages": [
      {"role": "system", "content": "You are a professional Chinese assistant."},
      {"role": "user", "content": "Please explain what a large language model is?"}
    ],
    "temperature": 0.7,
    "max_tokens": 1000
  }'
```

#### DeepSeek 示例

```bash theme={null}
# DeepSeek-V3 通用聊天（671B 参数）
curl -X POST "https://api.aisa.one/v1/chat/completions" \
  -H "Authorization: Bearer ***" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-v3",
    "messages": [{"role": "user", "content": "Write a quicksort algorithm in Python"}],
    "temperature": 0.3
  }'

# DeepSeek-R1 深度推理（支持 Tools）
curl -X POST "https://api.aisa.one/v1/chat/completions" \
  -H "Authorization: Bearer ***" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-r1",
    "messages": [{"role": "user", "content": "A farmer needs to cross a river with a wolf, a sheep, and a cabbage. The boat can only carry the farmer and one item at a time. If the farmer is not present, the wolf will eat the sheep, and the sheep will eat the cabbage. How can the farmer safely cross?"}]
  }'

# DeepSeek-V3.1 Terminus 最新版本
curl -X POST "https://api.aisa.one/v1/chat/completions" \
  -H "Authorization: Bearer ***" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-v3.1",
    "messages": [{"role": "user", "content": "Implement an LRU cache with get and put operations"}]
  }'
```

#### Qwen3 代码生成示例

```bash theme={null}
curl -X POST "https://api.aisa.one/v1/chat/completions" \
  -H "Authorization: Bearer ***" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen3-coder-plus",
    "messages": [{"role": "user", "content": "Implement a thread-safe Map in Go"}]
  }'
```

#### 参数参考

| 参数            | 类型      | 必填 | 描述                       |
| ------------- | ------- | -- | ------------------------ |
| `model`       | string  | 是  | 模型标识符                    |
| `messages`    | array   | 是  | 消息列表                     |
| `temperature` | number  | 否  | 随机性（0-2，默认 1）            |
| `max_tokens`  | integer | 否  | 最大生成 tokens              |
| `stream`      | boolean | 否  | 流式输出（默认 false）           |
| `top_p`       | number  | 否  | nucleus sampling 参数（0-1） |

#### 响应格式

```json theme={null}
{
  "id": "chatcmpl-xxx",
  "object": "chat.completion",
  "created": 1234567890,
  "model": "qwen-max",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "A large language model (LLM) is a deep learning-based..."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 30,
    "completion_tokens": 150,
    "total_tokens": 180,
    "cost": 0.001
  }
}
```

### 流式输出

```bash theme={null}
curl -X POST "https://api.aisa.one/v1/chat/completions" \
  -H "Authorization: Bearer ***" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen-plus",
    "messages": [{"role": "user", "content": "Tell a Chinese folk story"}],
    "stream": true
  }'
```

返回 Server-Sent Events（SSE）格式：

```
data: {"id":"chatcmpl-xxx","choices":[{"delta":{"content":"Once"}}]}
data: {"id":"chatcmpl-xxx","choices":[{"delta":{"content":" upon"}}]}
...
data: [DONE]
```

## Python 客户端

### CLI 用法

```bash theme={null}
# Qwen chat
python3 scripts/cn_llm_client.py chat --model qwen3-max --message "Hello, please introduce yourself"

# Qwen3 code generation
python3 scripts/cn_llm_client.py chat --model qwen3-coder-plus --message "Write a binary search algorithm"

# DeepSeek-R1 reasoning
python3 scripts/cn_llm_client.py chat --model deepseek-r1 --message "Which is larger, 9.9 or 9.11? Please reason in detail"

# DeepSeek-V3 chat
python3 scripts/cn_llm_client.py chat --model deepseek-v3 --message "Tell a story" --stream

# With system prompt
python3 scripts/cn_llm_client.py chat --model qwen3-max --system "You are a classical poetry expert" --message "Write a poem about plum blossoms"

# Model comparison
python3 scripts/cn_llm_client.py compare --models "qwen3-max,deepseek-v3" --message "What is quantum computing?"

# List supported models
python3 scripts/cn_llm_client.py models
```

### Python SDK 用法

```python theme={null}
from cn_llm_client import CNLLMClient

client = CNLLMClient()  # 使用 AISA_API_KEY 环境变量

response = client.chat(
    model="qwen3-max",
    messages=[{"role": "user", "content": "Hello!"}]
)
print(response["choices"][0]["message"]["content"])

for chunk in client.chat_stream(
    model="deepseek-v3",
    messages=[{"role": "user", "content": "Tell a story about an idiom"}]
):
    print(chunk, end="", flush=True)
```

## 使用场景

### 1. 中文内容生成

```python theme={null}
response = client.chat(
    model="qwen3-max",
    messages=[
        {"role": "system", "content": "You are a professional copywriter."},
        {"role": "user", "content": "Write a product introduction for a smart watch"}
    ]
)
```

### 2. 代码开发

```python theme={null}
response = client.chat(
    model="qwen3-coder-plus",
    messages=[{"role": "user", "content": "Implement a thread-safe Map in Go"}]
)
```

### 3. 复杂推理

```python theme={null}
response = client.chat(
    model="deepseek-r1",
    messages=[{"role": "user", "content": "Prove: For any positive integer n, n³-n is divisible by 6"}]
)
```

### 4. 视觉理解

```python theme={null}
response = client.chat(
    model="qwen3-vl-plus",
    messages=[
        {"role": "user", "content": [
            {"type": "text", "text": "Describe the content of this image"},
            {"type": "image_url", "image_url": {"url": "https://example.com/image.jpg"}}
        ]}
    ]
)
```

### 5. 模型路由策略

```python theme={null}
MODEL_MAP = {
    "chat": "qwen3-max",
    "code": "qwen3-coder-plus",
    "reasoning": "deepseek-r1",
    "vision": "qwen3-vl-plus",
    "fast": "qwen3-coder-flash",
    "translate": "qwen-mt-flash"
}

def route_by_task(task_type: str, message: str) -> str:
    model = MODEL_MAP.get(task_type, "qwen3-max")
    return client.chat(model=model, messages=[{"role": "user", "content": message}])
```

## 错误处理

错误以 JSON 返回，包含 `error` 字段：

```json theme={null}
{
  "error": {
    "code": "model_not_found",
    "message": "Model 'xxx' is not available"
  }
}
```

常见错误码：

* `401` - API Key 无效或缺失
* `402` - 余额不足
* `404` - 模型不存在
* `429` - 超出速率限制
* `500` - 服务器错误

## 价格

| 模型                | 输入 (\$/M) | 输出 (\$/M) |
| ----------------- | --------- | --------- |
| qwen3-max         | \$1.37    | \$5.48    |
| qwen3-coder-plus  | \$2.86    | \$28.60   |
| qwen3-coder-flash | \$0.72    | \$3.60    |
| qwen3-vl-plus     | \$0.43    | \$4.30    |
| deepseek-v3       | \$1.00    | \$4.00    |
| deepseek-r1       | \$2.00    | \$8.00    |
| deepseek-v3.1     | \$4.00    | \$12.00   |

> 价格单位为每百万 tokens。每个响应包含 `usage.cost` 和 `usage.credits_remaining`。

## 开始使用

1. 在 [aisa.one](https://aisa.one) 注册（新账户有 \$2 免费额度）。
2. 从控制台生成 API key。
3. 设置 key 并安装技能：
   ```bash theme={null}
   export AISA_API_KEY="your-key"
   npm install -g @aisa-one/cli
   aisa skills install cn-llm
   ```
4. 启动新的 Agent 会话，让运行时加载更新后的技能说明。

## 相关

<CardGroup cols={3}>
  <Card title="中国 LLM" icon="language" href="/zh/guides/chinese-llms">
    AIsa 中中文模型家族的概览。
  </Card>

  <Card title="AIsa LLM Router" icon="route" href="/zh/agent-skills/llm-router">
    面向多 provider 的通用模型路由。
  </Card>

  <Card title="模型目录" icon="list" href="/zh/guides/models">
    浏览支持的 model ID。
  </Card>
</CardGroup>
