快速接入混元、GLM、Kimi等大模型能力
本教程涵盖Python、Node.js等主流语言的API接入方法,帮你快速构建AI应用。
第一步:注册腾讯云账号,完成实名认证。
第二步:开通大模型服务,获取SecretId和SecretKey。
第三步:选择适合你的编程语言和SDK。
第四步:阅读API文档,了解接口规范。
pip install tencentcloud-sdk-python
from tencentcloud.common import credential
from tencentcloud.hunyuan.v20230901 import hunyuan_client
cred = credential.Credential(
"你的SecretId",
"你的SecretKey"
)
client = hunyuan_client.HunyuanClient(cred, "ap-beijing")
response = client.ChatCompletion({
"Messages": [
{"Role": "user", "Content": "你好"}
]
})
print(response.Choices[0].Message.Content)
response = client.ChatCompletion({
"Messages": [
{"Role": "user", "Content": "写一首诗"}
],
"Stream": True
})
for event in response:
print(event.Choices[0].Delta.Content, end="")
npm install tencentcloud-sdk-nodejs
const tencentcloud = require("tencentcloud-sdk-nodejs");
const HunyuanClient = tencentcloud.hunyuan.v20230901.Client;
const client = new HunyuanClient({
credential: {
secretId: "你的SecretId",
secretKey: "你的SecretKey"
},
region: "ap-beijing"
});
const response = await client.ChatCompletion({
Messages: [{ Role: "user", Content: "你好" }]
});
console.log(response.Choices[0].Message.Content);
| 模型 | 特点 | 适用场景 | 推荐指数 |
|---|---|---|---|
| Tencent HY 2.0 | 代码生成强,长上下文 | Coding Agent、文档自动化 | ⭐⭐⭐⭐⭐ |
| GLM-5 | 复杂系统工程 | 长程Agent任务、编程 | ⭐⭐⭐⭐ |
| Kimi-K2.5 | 多模态、思考模式 | 对话、视觉理解 | ⭐⭐⭐⭐ |
| MiniMax-M2.5 | 生产力场景优化 | 办公、复杂多步任务 | ⭐⭐⭐⭐ |
| DeepSeek-V4-Flash | 高并发、低延迟 | 生产级应用、经济之选 | ⭐⭐⭐ |
💡 还想查看更多模型的价格和参数对比?我们的 AI模型服务对比 页面汇总了腾讯云、智谱GLM、MiniMax、Kimi、DeepSeek等平台的详细价格和模型参数,一页看懂。
是的,默认QPS限制为10次/秒。如需更高频率,可以在控制台申请提升配额。
1个Token约等于0.7个中文汉字或1个英文单词。输入和输出分别计费。
建议使用Token Plan套餐,比按量计费便宜50%-80%。同时可以缓存常用响应,减少重复调用。