大模型 API 大全:国内外主流模型接口汇总(2026 版)
·
2026 年了,市面上的大模型多到让人眼花缭乱。OpenAI、Claude、Gemini、通义千问、DeepSeek、Kimi、文心一言……每家的 API 格式不同、价格不同、能力也不同。这篇文章帮你一次搞清楚所有主流大模型 API,附带代码示例、价格对比和选型建议,建议收藏!
目录
第一章:国际篇
1.1 OpenAI — 行业标杆
| 项目 | 信息 |
|---|---|
| 官网 | https://platform.openai.com |
| API 文档 | https://platform.openai.com/docs |
| Base URL | https://api.openai.com/v1 |
| 认证方式 | Bearer Token |
| 主流模型 | GPT-4o, GPT-4o-mini, o1, o3 |
模型矩阵:
| 模型 | 定位 | 输入价格 ($/1M tokens) | 输出价格 ($/1M tokens) | 上下文窗口 |
|---|---|---|---|---|
| GPT-4o | 旗舰多模态 | $2.50 | $10.00 | 128K |
| GPT-4o-mini | 高性价比 | $0.15 | $0.60 | 128K |
| o3 | 深度推理 | $10.00 | $40.00 | 200K |
| o4-mini | 推理性价比 | $1.10 | $4.40 | 200K |
快速接入:
from openai import OpenAI
client = OpenAI(api_key="sk-xxxxxxxxxxxxxxxx")
response = client.chat.completions.create(
model="gpt-4o",
messages=[
{"role": "system", "content": "你是一名资深 DBA"},
{"role": "user", "content": "SQL Server 死锁怎么排查?"}
]
)
print(response.choices[0].message.content)
特点:
- 生态最成熟,SDK 和文档最完善
- 几乎所有国内模型都兼容 OpenAI 的 API 格式
- 价格偏贵,但能力天花板高
- 需要科学上网
1.2 Anthropic Claude — 编程与长文本之王
| 项目 | 信息 |
|---|---|
| 官网 | https://www.anthropic.com |
| API 文档 | https://docs.anthropic.com |
| Base URL | https://api.anthropic.com/v1 |
| 认证方式 | API Key (Header: x-api-key) |
| 主流模型 | Claude Opus 4, Claude Sonnet 4, Claude Haiku 3.5 |
模型矩阵:
| 模型 | 定位 | 输入价格 ($/1M tokens) | 输出价格 ($/1M tokens) | 上下文窗口 |
|---|---|---|---|---|
| Claude Opus 4 | 旗舰推理 | $15.00 | $75.00 | 200K |
| Claude Sonnet 4 | 均衡主力 | $3.00 | $15.00 | 200K |
| Claude Haiku 3.5 | 快速低价 | $0.80 | $4.00 | 200K |
快速接入:
import anthropic
client = anthropic.Anthropic(api_key="sk-ant-xxxxxxxxxxxxxxxx")
response = client.messages.create(
model="claude-sonnet-4-20250514",
max_tokens=4096,
messages=[
{"role": "user", "content": "帮我写一个 Python 爬虫"}
]
)
print(response.content[0].text)
特点:
- 代码生成能力业界顶级
- 超长上下文(200K tokens)
- 安全性设计出色,拒绝率低
- API 格式与 OpenAI 不同,需要注意
1.3 Google Gemini — 谷歌的多模态大模型
| 项目 | 信息 |
|---|---|
| 官网 | https://ai.google.dev |
| API 文档 | https://ai.google.dev/docs |
| Base URL | https://generativelanguage.googleapis.com/v1beta |
| 认证方式 | API Key (Query Param) |
| 主流模型 | Gemini 2.5 Pro, Gemini 2.5 Flash |
模型矩阵:
| 模型 | 定位 | 输入价格 ($/1M tokens) | 输出价格 ($/1M tokens) | 上下文窗口 |
|---|---|---|---|---|
| Gemini 2.5 Pro | 旗舰多模态 | $1.25 | $10.00 | 1M |
| Gemini 2.5 Flash | 高速多模态 | $0.15 | $0.60 | 1M |
| Gemini 2.0 Flash | 轻量级 | 免费额度充足 | 免费额度充足 | 1M |
快速接入:
import google.generativeai as genai
genai.configure(api_key="AIzaxxxxxxxxxxxxxxxx")
model = genai.GenerativeModel("gemini-2.5-pro")
response = model.generate_content("解释一下什么是 Transformer 架构")
print(response.text)
特点:
- 百万级上下文窗口,处理超长文档无敌
- 多模态能力强(文本、图片、视频、音频)
- Flash 模型免费额度慷慨
- 国内访问需要代理
1.4 Meta Llama — 开源模型标杆
| 项目 | 信息 |
|---|---|
| 开源地址 | https://llama.meta.com |
| 模型 | Llama 4, Llama 3.3, Llama 3.2 |
| 使用方式 | 自部署 / 通过 API 提供商调用 |
| 许可证 | Llama 社区许可 |
模型矩阵:
| 模型 | 参数量 | 特点 |
|---|---|---|
| Llama 4 Scout | 17B 激活 | MoE 架构,10M 上下文 |
| Llama 4 Maverick | 17B 激活 | MoE,多模态,400K 上下文 |
| Llama 3.3 70B | 70B | 纯文本,性价比之王 |
| Llama 3.2 8B | 8B | 轻量级,适合端侧部署 |
通过 API 提供商调用(无需自部署):
# 方式一:通过 Groq(超快推理)
from openai import OpenAI
client = OpenAI(
api_key="gsk_xxxxxxxx",
base_url="https://api.groq.com/openai/v1"
)
response = client.chat.completions.create(
model="llama-3.3-70b-versatile",
messages=[{"role": "user", "content": "Hello!"}]
)
# 方式二:通过 Together AI
client2 = OpenAI(
api_key="xxxxxxxx",
base_url="https://api.together.xyz/v1"
)
response2 = client2.chat.completions.create(
model="meta-llama/Llama-3.3-70B-Instruct-Turbo",
messages=[{"role": "user", "content": "Hello!"}]
)
特点:
- 完全开源,可私有化部署,数据不出域
- 通过 Groq 调用速度极快(800+ tokens/s)
- 社区生态丰富,微调方案多
- 中文能力相对国产模型稍弱
1.5 Mistral — 欧洲之光
| 项目 | 信息 |
|---|---|
| 官网 | https://mistral.ai |
| API 文档 | https://docs.mistral.ai |
| Base URL | https://api.mistral.ai/v1 |
| 认证方式 | Bearer Token |
模型矩阵:
| 模型 | 定位 | 输入价格 ($/1M tokens) | 输出价格 ($/1M tokens) |
|---|---|---|---|
| Mistral Large | 旗舰 | $2.00 | $6.00 |
| Mistral Medium | 均衡 | $2.70 | $8.10 |
| Mistral Small | 轻量 | $0.10 | $0.30 |
| Codestral | 代码专精 | $0.30 | $0.90 |
快速接入(兼容 OpenAI 格式):
from openai import OpenAI
client = OpenAI(
api_key="xxxxxxxxxxxxxxxx",
base_url="https://api.mistral.ai/v1"
)
response = client.chat.completions.create(
model="mistral-large-latest",
messages=[{"role": "user", "content": "Bonjour!"}]
)
特点:
- 小模型性价比极高(Small 模型 $0.10/1M 输入)
- Codestral 专攻代码生成
- 欧洲公司,数据隐私合规(GDPR)
- 兼容 OpenAI API 格式
1.6 Cohere — 企业级 RAG 专家
| 项目 | 信息 |
|---|---|
| 官网 | https://cohere.com |
| API 文档 | https://docs.cohere.com |
| Base URL | https://api.cohere.ai/v2 |
| 主流模型 | Command R+, Command R, Embed v3 |
模型矩阵:
| 模型 | 定位 | 价格 ($/1M tokens) | 特点 |
|---|---|---|---|
| Command R+ | 旗舰 | 输入 $2.50 / 输出 $10.00 | RAG 优化,引用溯源 |
| Command R | 均衡 | 输入 $0.15 / 输出 $0.60 | 多语言支持好 |
| Embed v3 | 向量嵌入 | $0.10 / 1M tokens | 多语言 Embedding |
特点:
- RAG 场景原生优化,自带引用溯源
- Embed v3 是多语言 Embedding 的优秀选择
- 企业级数据安全保障
- 支持 100+ 语言
第二章:国内篇
2.1 阿里通义千问(百炼平台)
| 项目 | 信息 |
|---|---|
| 官网 | https://bailian.console.aliyun.com |
| API 文档 | https://help.aliyun.com/zh/model-studio |
| Base URL | https://dashscope.aliyuncs.com/compatible-mode/v1 |
| 认证方式 | Bearer Token(兼容 OpenAI 格式) |
模型矩阵:
| 模型 | 定位 | 输入价格 (元/千 tokens) | 输出价格 (元/千 tokens) | 上下文窗口 |
|---|---|---|---|---|
| qwen-max-latest | 旗舰 | ¥0.020 | ¥0.060 | 128K |
| qwen-plus-latest | 均衡 | ¥0.004 | ¥0.012 | 131K |
| qwen-turbo-latest | 高速 | ¥0.002 | ¥0.006 | 131K |
| qwen-coder-plus | 代码 | ¥0.002 | ¥0.006 | 131K |
| qwen-long | 长文本 | ¥0.0005 | ¥0.002 | 10M |
快速接入:
from openai import OpenAI
client = OpenAI(
api_key="sk-xxxxxxxxxxxxxxxx", # 百炼 API Key
base_url="https://dashscope.aliyuncs.com/compatible-mode/v1"
)
response = client.chat.completions.create(
model="qwen-max-latest",
messages=[
{"role": "system", "content": "你是一名资深 DBA"},
{"role": "user", "content": "SQL Server 性能优化有哪些方法?"}
]
)
print(response.choices[0].message.content)
特点:
- 完全兼容 OpenAI API 格式,切换成本为零
- qwen-long 支持千万级上下文(10M tokens)
- 中文能力第一梯队
- 价格极具竞争力,turbo 模型几乎白菜价
- 支持 Function Calling、多模态
2.2 DeepSeek — 国产性价比之王
| 项目 | 信息 |
|---|---|
| 官网 | https://platform.deepseek.com |
| API 文档 | https://api-docs.deepseek.com |
| Base URL | https://api.deepseek.com/v1 |
| 认证方式 | Bearer Token(兼容 OpenAI 格式) |
模型矩阵:
| 模型 | 定位 | 输入价格 (元/千 tokens) | 输出价格 (元/千 tokens) | 上下文窗口 |
|---|---|---|---|---|
| DeepSeek-V3 | 旗舰通用 | ¥0.001 | ¥0.002 | 128K |
| DeepSeek-R1 | 深度推理 | ¥0.004 | ¥0.016 | 128K |
| DeepSeek-V3-0324 | 最新版本 | ¥0.001 | ¥0.002 | 128K |
快速接入:
from openai import OpenAI
client = OpenAI(
api_key="sk-xxxxxxxxxxxxxxxx",
base_url="https://api.deepseek.com/v1"
)
response = client.chat.completions.create(
model="deepseek-chat", # 或 deepseek-reasoner
messages=[{"role": "user", "content": "用 Python 写一个归并排序"}]
)
print(response.choices[0].message.content)
特点:
- 价格极低,V3 模型输入仅 ¥0.001/千 tokens
- R1 推理模型能力媲美 OpenAI o1
- 完全兼容 OpenAI API 格式
- 代码能力强劲
- 开源模型(DeepSeek-V3、DeepSeek-R1)可私有部署
2.3 月之暗面 Kimi(Moonshot AI)
| 项目 | 信息 |
|---|---|
| 官网 | https://platform.moonshot.cn |
| API 文档 | https://platform.moonshot.cn/docs |
| Base URL | https://api.moonshot.cn/v1 |
| 认证方式 | Bearer Token(兼容 OpenAI 格式) |
模型矩阵:
| 模型 | 定位 | 输入价格 (元/千 tokens) | 输出价格 (元/千 tokens) | 上下文窗口 |
|---|---|---|---|---|
| moonshot-v1-8k | 短文本 | ¥0.012 | ¥0.012 | 8K |
| moonshot-v1-32k | 中文本 | ¥0.024 | ¥0.024 | 32K |
| moonshot-v1-128k | 长文本 | ¥0.060 | ¥0.060 | 128K |
快速接入:
from openai import OpenAI
client = OpenAI(
api_key="sk-xxxxxxxxxxxxxxxx",
base_url="https://api.moonshot.cn/v1"
)
response = client.chat.completions.create(
model="moonshot-v1-128k",
messages=[{"role": "user", "content": "总结一下这篇 10 万字的报告"}]
)
print(response.choices[0].message.content)
特点:
- 超长上下文处理能力强(128K 起步)
- 长文档理解和总结能力出色
- 兼容 OpenAI API 格式
- 适合需要处理大量文档的场景
2.4 百度文心一言(ERNIE)
| 项目 | 信息 |
|---|---|
| 官网 | https://qianfan.cloud.baidu.com |
| API 文档 | https://cloud.baidu.com/doc/WENXINWORKSHOP |
| Base URL | https://qianfan.baidubce.com/v2/chat/completions |
| 认证方式 | Bearer Token(兼容 OpenAI 格式) |
模型矩阵:
| 模型 | 定位 | 输入价格 (元/千 tokens) | 输出价格 (元/千 tokens) |
|---|---|---|---|
| ERNIE 4.0 | 旗舰 | ¥0.030 | ¥0.090 |
| ERNIE 3.5 | 均衡 | ¥0.0008 | ¥0.002 |
| ERNIE Speed | 高速 | 免费 | 免费 |
快速接入:
from openai import OpenAI
client = OpenAI(
api_key="bce-v3/xxxxxxxx",
base_url="https://qianfan.baidubce.com/v2"
)
response = client.chat.completions.create(
model="ernie-4.0-8k-latest",
messages=[{"role": "user", "content": "写一首关于春天的诗"}]
)
print(response.choices[0].message.content)
特点:
- ERNIE Speed 免费额度足够个人使用
- 中文理解和生成能力优秀
- 深度集成百度生态(搜索、知识图谱)
- 已兼容 OpenAI API 格式
2.5 智谱 ChatGLM / GLM-4
| 项目 | 信息 |
|---|---|
| 官网 | https://open.bigmodel.cn |
| API 文档 | https://open.bigmodel.cn/dev/api |
| Base URL | https://open.bigmodel.cn/api/paas/v4 |
| 认证方式 | API Key (Header) |
模型矩阵:
| 模型 | 定位 | 输入价格 (元/千 tokens) | 输出价格 (元/千 tokens) |
|---|---|---|---|
| GLM-4-Plus | 旗舰 | ¥0.050 | ¥0.050 |
| GLM-4-Air | 均衡 | ¥0.001 | ¥0.001 |
| GLM-4-Flash | 高速 | 免费 | 免费 |
| GLM-4V | 多模态 | ¥0.004 | ¥0.004 |
快速接入:
from zhipuai import ZhipuAI
client = ZhipuAI(api_key="xxxxxxxxxxxxxxxx")
response = client.chat.completions.create(
model="glm-4-plus",
messages=[{"role": "user", "content": "解释量子计算的基本原理"}]
)
print(response.choices[0].message.content)
特点:
- GLM-4-Flash 完全免费,注册即用
- 模型开源(ChatGLM 系列),可私有部署
- 多模态模型 GLM-4V 性价比高
- 学术背景深厚,研究能力强
2.6 字节跳动豆包(火山引擎)
| 项目 | 信息 |
|---|---|
| 官网 | https://www.volcengine.com/product/doubao |
| API 文档 | https://www.volcengine.com/docs/82379 |
| Base URL | https://ark.cn-beijing.volces.com/api/v3 |
| 认证方式 | Bearer Token(兼容 OpenAI 格式) |
模型矩阵:
| 模型 | 定位 | 输入价格 (元/千 tokens) | 输出价格 (元/千 tokens) |
|---|---|---|---|
| Doubao-pro | 旗舰 | ¥0.0008 | ¥0.002 |
| Doubao-lite | 轻量 | ¥0.0004 | ¥0.001 |
快速接入:
from openai import OpenAI
client = OpenAI(
api_key="xxxxxxxxxxxxxxxx",
base_url="https://ark.cn-beijing.volces.com/api/v3"
)
response = client.chat.completions.create(
model="doubao-pro-32k", # endpoint ID
messages=[{"role": "user", "content": "帮我分析一下这段代码的性能问题"}]
)
print(response.choices[0].message.content)
特点:
- 价格极低,Pro 模型输入仅 ¥0.0008/千 tokens
- 与字节跳动生态深度集成
- 兼容 OpenAI API 格式
- 使用 endpoint ID 而非模型名,需先在控制台创建
2.7 腾讯混元
| 项目 | 信息 |
|---|---|
| 官网 | https://cloud.tencent.com/product/hunyuan |
| API 文档 | https://cloud.tencent.com/document/product/1729 |
| 认证方式 | SecretId + SecretKey(腾讯云签名) |
模型矩阵:
| 模型 | 定位 | 输入价格 (元/千 tokens) | 输出价格 (元/千 tokens) |
|---|---|---|---|
| hunyuan-pro | 旗舰 | ¥0.030 | ¥0.100 |
| hunyuan-standard | 均衡 | ¥0.004 | ¥0.008 |
| hunyuan-lite | 轻量 | 免费 | 免费 |
快速接入:
# 腾讯混元使用 OpenAI 兼容模式
from openai import OpenAI
client = OpenAI(
api_key="xxxxxxxxxxxxxxxx",
base_url="https://api.hunyuan.cloud.tencent.com/v1"
)
response = client.chat.completions.create(
model="hunyuan-lite",
messages=[{"role": "user", "content": "你好"}]
)
print(response.choices[0].message.content)
特点:
- hunyuan-lite 完全免费
- 深度集成腾讯云和微信生态
- 适合微信生态内的应用开发
2.8 讯飞星火
| 项目 | 信息 |
|---|---|
| 官网 | https://www.xfyun.cn/doc/spark |
| API 文档 | https://www.xfyun.cn/doc/spark/Web.html |
| 认证方式 | WebSocket / HTTP |
模型矩阵:
| 模型 | 定位 | 价格 |
|---|---|---|
| Spark 4.0 Ultra | 旗舰 | 按 token 计费 |
| Spark Pro | 均衡 | 按 token 计费 |
| Spark Lite | 轻量 | 免费额度 |
特点:
- 语音识别 + 大模型联动能力强
- 教育、医疗领域有深度优化
- 适合语音交互类应用
第三章:代码示例大全
3.1 统一调用封装(一个函数调用所有模型)
由于大多数国内外模型都兼容 OpenAI 格式,我们可以写一个统一封装:
from openai import OpenAI
# 模型配置表
MODEL_CONFIGS = {
"openai": {
"base_url": "https://api.openai.com/v1",
"api_key": "sk-xxxxxxxx",
"model": "gpt-4o"
},
"qwen": {
"base_url": "https://dashscope.aliyuncs.com/compatible-mode/v1",
"api_key": "sk-xxxxxxxx",
"model": "qwen-max-latest"
},
"deepseek": {
"base_url": "https://api.deepseek.com/v1",
"api_key": "sk-xxxxxxxx",
"model": "deepseek-chat"
},
"moonshot": {
"base_url": "https://api.moonshot.cn/v1",
"api_key": "sk-xxxxxxxx",
"model": "moonshot-v1-128k"
},
"groq-llama": {
"base_url": "https://api.groq.com/openai/v1",
"api_key": "gsk_xxxxxxxx",
"model": "llama-3.3-70b-versatile"
},
"mistral": {
"base_url": "https://api.mistral.ai/v1",
"api_key": "xxxxxxxx",
"model": "mistral-large-latest"
},
}
def ask_llm(provider: str, question: str, system_prompt: str = None) -> str:
"""
统一调用各大模型 API
"""
config = MODEL_CONFIGS[provider]
client = OpenAI(
api_key=config["api_key"],
base_url=config["base_url"]
)
messages = []
if system_prompt:
messages.append({"role": "system", "content": system_prompt})
messages.append({"role": "user", "content": question})
response = client.chat.completions.create(
model=config["model"],
messages=messages
)
return response.choices[0].message.content
# 使用示例
answer = ask_llm("deepseek", "SQL Server 索引碎片怎么处理?")
print(answer)
# 换个模型试试
answer2 = ask_llm("qwen", "SQL Server 索引碎片怎么处理?")
print(answer2)
3.2 流式输出(Streaming)
from openai import OpenAI
client = OpenAI(
api_key="sk-xxxxxxxx",
base_url="https://dashscope.aliyuncs.com/compatible-mode/v1"
)
stream = client.chat.completions.create(
model="qwen-max-latest",
messages=[{"role": "user", "content": "写一篇 3000 字的 AI 发展史"}],
stream=True # 开启流式输出
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)
3.3 Function Calling / Tool Use
import json
from openai import OpenAI
client = OpenAI(
api_key="sk-xxxxxxxx",
base_url="https://dashscope.aliyuncs.com/compatible-mode/v1"
)
# 定义工具
tools = [
{
"type": "function",
"function": {
"name": "get_db_status",
"description": "获取数据库实例的运行状态",
"parameters": {
"type": "object",
"properties": {
"instance_name": {
"type": "string",
"description": "数据库实例名称"
}
},
"required": ["instance_name"]
}
}
}
]
# 你的工具实现
def get_db_status(instance_name):
# 实际查询数据库状态的逻辑
return json.dumps({
"instance": instance_name,
"status": "running",
"cpu_usage": "45%",
"memory_usage": "68%",
"connections": 230
})
# 调用模型
response = client.chat.completions.create(
model="qwen-max-latest",
messages=[{"role": "user", "content": "查看 PROD-DB-01 的运行状态"}],
tools=tools,
tool_choice="auto"
)
# 处理工具调用
message = response.choices[0].message
if message.tool_calls:
for tool_call in message.tool_calls:
if tool_call.function.name == "get_db_status":
args = json.loads(tool_call.function.arguments)
result = get_db_status(args["instance_name"])
# 把结果返回给模型
response2 = client.chat.completions.create(
model="qwen-max-latest",
messages=[
{"role": "user", "content": "查看 PROD-DB-01 的运行状态"},
message,
{
"role": "tool",
"tool_call_id": tool_call.id,
"content": result
}
]
)
print(response2.choices[0].message.content)
3.4 Claude API 调用示例(非 OpenAI 格式)
import anthropic
client = anthropic.Anthropic(api_key="sk-ant-xxxxxxxxxxxxxxxx")
# 基础调用
response = client.messages.create(
model="claude-sonnet-4-20250514",
max_tokens=4096,
system="你是一名资深 DBA,擅长 SQL Server 性能优化。",
messages=[
{"role": "user", "content": "如何排查 SQL Server 死锁?"}
]
)
print(response.content[0].text)
print(f"输入 tokens: {response.usage.input_tokens}")
print(f"输出 tokens: {response.usage.output_tokens}")
3.5 Gemini API 调用示例
import google.generativeai as genai
genai.configure(api_key="AIzaxxxxxxxxxxxxxxxx")
model = genai.GenerativeModel(
model_name="gemini-2.5-pro",
system_instruction="你是一名资深 DBA"
)
# 单轮对话
response = model.generate_content("SQL Server 死锁怎么排查?")
print(response.text)
# 多轮对话
chat = model.start_chat(history=[])
chat.send_message("什么是数据库索引?")
chat.send_message("那聚簇索引和非聚簇索引有什么区别?")
print(chat.history[-1].parts[0].text)
第四章:价格与能力横评
4.1 输入价格排行(从低到高)
| 排名 | 模型 | 输入价格 | 备注 |
|---|---|---|---|
| 1 | Gemini 2.0 Flash | 免费 | 有免费额度上限 |
| 2 | GLM-4-Flash | 免费 | 注册即用 |
| 3 | ERNIE Speed | 免费 | 百度生态 |
| 4 | hunyuan-lite | 免费 | 腾讯生态 |
| 5 | DeepSeek-V3 | ¥0.001/千 tokens | 极致性价比 |
| 6 | Doubao-lite | ¥0.0004/千 tokens | 字节生态 |
| 7 | qwen-turbo | ¥0.002/千 tokens | 阿里云 |
| 8 | GPT-4o-mini | $0.15/1M tokens | 约 ¥1.1/千 tokens |
| 9 | Mistral Small | $0.10/1M tokens | 约 ¥0.7/千 tokens |
| 10 | Claude Haiku 3.5 | $0.80/1M tokens | 约 ¥5.8/千 tokens |
4.2 旗舰模型对比
| 维度 | GPT-4o | Claude Sonnet 4 | Gemini 2.5 Pro | qwen-max | DeepSeek-V3 |
|---|---|---|---|---|---|
| 通用能力 | 强 | 极强 | 强 | 强 | 强 |
| 代码能力 | 强 | 极强 | 强 | 强 | 强 |
| 中文能力 | 中 | 中 | 中 | 极强 | 极强 |
| 推理能力 | 强 | 强 | 强 | 强 | 强 |
| 多模态 | 文本+图片+音频 | 文本+图片 | 文本+图片+视频+音频 | 文本+图片 | 文本+图片 |
| 上下文 | 128K | 200K | 1M | 128K | 128K |
| 价格 | 贵 | 贵 | 中 | 低 | 极低 |
| 国内可访问 | 需代理 | 需代理 | 需代理 | 直接访问 | 直接访问 |
4.3 国产模型价格 PK
| 模型 | 输入 (元/千 tokens) | 输出 (元/千 tokens) | 综合性价比 |
|---|---|---|---|
| DeepSeek-V3 | ¥0.001 | ¥0.002 | 极致 |
| Doubao-lite | ¥0.0004 | ¥0.001 | 极致 |
| qwen-turbo | ¥0.002 | ¥0.006 | 很高 |
| ERNIE 3.5 | ¥0.0008 | ¥0.002 | 很高 |
| GLM-4-Air | ¥0.001 | ¥0.001 | 高 |
| Moonshot-v1-8k | ¥0.012 | ¥0.012 | 中等 |
第五章:选型指南
5.1 按场景选型
| 场景 | 推荐模型 | 理由 |
|---|---|---|
| 个人学习/研究 | GLM-4-Flash / ERNIE Speed | 免费,够用 |
| 轻量级聊天机器人 | DeepSeek-V3 / qwen-turbo | 极低价格,中文能力强 |
| 企业知识库 RAG | qwen-plus / Command R+ | RAG 优化,成本可控 |
| 代码生成/辅助编程 | Claude Sonnet 4 / DeepSeek-R1 | 代码能力顶级 |
| 复杂推理/分析 | GPT-4o / o3 / DeepSeek-R1 | 推理能力强 |
| 超长文档处理 | Gemini 2.5 Pro / qwen-long | 百万级上下文 |
| 多模态应用 | Gemini 2.5 Pro / GPT-4o | 文本+图片+视频+音频 |
| 数据安全/私有部署 | Llama / DeepSeek / ChatGLM | 开源,可自部署 |
| 预算充足不差钱 | GPT-4o + Claude Sonnet 4 | 能力天花板 |
5.2 按预算选型
| 月预算 | 推荐方案 |
|---|---|
| 免费 | GLM-4-Flash + ERNIE Speed + hunyuan-lite |
| < 100 元 | DeepSeek-V3 主力 + qwen-turbo 备用 |
| 100-1000 元 | qwen-plus 主力 + DeepSeek-V3 兜底 |
| 1000-10000 元 | GPT-4o-mini + qwen-max + DeepSeek-V3 |
| > 10000 元 | GPT-4o + Claude Sonnet 4 + 国产兜底 |
5.3 最佳实践:多模型路由
聪明的做法不是只选一个模型,而是根据任务复杂度动态路由:
def smart_route(question: str) -> str:
"""
智能路由:简单问题用便宜模型,复杂问题用强模型
"""
# 1. 先用便宜模型判断问题复杂度
classifier = OpenAI(
api_key="sk-xxx",
base_url="https://dashscope.aliyuncs.com/compatible-mode/v1"
)
classify_result = classifier.chat.completions.create(
model="qwen-turbo-latest",
messages=[{
"role": "system",
"content": "判断问题的复杂度,只回答 'simple' 或 'complex'"
}, {
"role": "user",
"content": question
}]
)
complexity = classify_result.choices[0].message.content.strip()
# 2. 根据复杂度路由到不同模型
if complexity == "simple":
# 简单问题 -> 便宜模型(DeepSeek-V3,¥0.001/千tokens)
return ask_llm("deepseek", question)
else:
# 复杂问题 -> 强模型(GPT-4o)
return ask_llm("openai", question)
总结
核心结论
- 国内模型首选:DeepSeek-V3(最便宜)、通义千问(最全面)、智谱 GLM(免费模型)
- 国际模型首选:Claude Sonnet 4(代码最强)、GPT-4o(综合能力最强)、Gemini 2.5 Pro(最长上下文)
- 兼容性最佳:几乎所有国内模型都兼容 OpenAI API 格式,切换只改
base_url和api_key - 性价比策略:多模型路由,简单问题用便宜模型,复杂问题用强模型
一句话总结
选大模型就像选数据库——没有最好的,只有最适合的。了解每家的价格和能力,根据场景动态路由,才是最聪明的做法。
相关阅读
关于作者
一名天天和各家大模型 API 打交道的技术人。写这篇文章的初衷是:每次换模型都要查一遍文档,不如一次整理全,以后换模型只改两行代码。
更多推荐





所有评论(0)