跳转到主要内容
在 GitHub 上查看 -> 通过 AIsa 进行中文 LLM 路由。 将中文任务发送到 Qwen、DeepSeek、GLM、Baichuan 及相关模型家族。

安装

如果还没有安装 AIsa CLI,请先安装:
npm install -g @aisa-one/cli
然后安装该技能:
aisa skills install cn-llm

Agent 可以用它做什么?

中文提示

将中文任务路由到强大的中文 LLM。

模型选择

在 Qwen、DeepSeek、GLM、Baichuan 及相关模型间选择。

双语工作流

在中文模型和全球模型家族之间切换。

Agent 默认策略

为 Agent 提供实用的路由启发式规则。

🔥 可以做什么

智能聊天

"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/M480B 大模型
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/MPlus 版本
qwen-mt-flash$0.168/M$0.514/M快速机器翻译
qwen-mt-lite$0.13/M$0.39/MLite 机器翻译

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/MV3 稳定版本
deepseek-v3.1$4.00/M$12.00/M最新 Terminus 版本
注意:价格中的 M 表示 million tokens。模型可用性可能变化,请查看 console.aisa.one/pricing 获取最新列表。

快速开始

export AISA_API_KEY="your-key"

API 端点

OpenAI 兼容接口

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

Qwen 示例

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 示例

# 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 代码生成示例

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

参数参考

参数类型必填描述
modelstring模型标识符
messagesarray消息列表
temperaturenumber随机性(0-2,默认 1)
max_tokensinteger最大生成 tokens
streamboolean流式输出(默认 false)
top_pnumbernucleus sampling 参数(0-1)

响应格式

{
  "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
  }
}

流式输出

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 用法

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

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. 中文内容生成

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. 代码开发

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

3. 复杂推理

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

4. 视觉理解

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. 模型路由策略

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 字段:
{
  "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.costusage.credits_remaining

开始使用

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

相关

中国 LLM

AIsa 中中文模型家族的概览。

AIsa LLM Router

面向多 provider 的通用模型路由。

模型目录

浏览支持的 model ID。