混元 Hunyuan 系列大模型 API 接口

腾讯混元大模型(Tencent Hunyuan)由腾讯公司全链路自研,在高质量的内容创作、数理逻辑、代码生成、多轮对话、图像与视频生产上性能表现优越,处于业界领先水平。


此文档为标准版 API 接口文档,可直接用于项目开发和系统调用。如果标准版 API 接口无法满足您的需求,需要定制开发 API 接口,请联系我们的 IT 技术支持工程师:

详细信息 定制开发服务流程:沟通需求✅ → 确认技术方案✅ → 沟通费用与工期✅ → 开发&测试✅ → 验收交付✅ → 维护升级✅

接口地址

POST https://wcode.net/api/gpt/v1/chat/completions

此 API 接口兼容 OpenAI 的接口规范,也就是可以直接使用 OpenAI 的 SDK 来调用各个模型。仅需替换以下两项配置:

  1. BASE_URL 替换为 https://wcode.net/api/gpt/v1
  2. API_KEY 替换为从 https://wcode.net/get-apikey 获取到的 API KEY

即可开始使用 OpenAI SDK 调用 通义千问系列豆包系列DeepSeek系列文心一言系列混元系列......等各个模型

请求方法

POST

快速开始(请求示例)

(注:以下请求示例中的 API_KEY 需要替换后再发起请求。 获取 API_KEY 入口:https://wcode.net/get-apikey

curl --request POST 'https://wcode.net/api/gpt/v1/chat/completions' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer API_KEY' \
--data '{
    "model": "hunyuan-standard",
    "messages": [
        {
            "role": "user",
            "content": "你好,请介绍一下你自己"
        }
    ]
}'

请求头(Request Headers)

Header 备注 示例 相关链接
Authorization Bearer API_KEY 格式:Bearer + 空格 + API_KEY Bearer sk-..... 获取 API_KEY 入口:https://wcode.net/get-apikey
Content-Type application/json 固定为 application/json

请求参数

🚀 model | ✅️必填 | string | 模型ID,可选 model 模型列表(部分):

模型ID 模型名称 模型能力 每千tokens输入 每千tokens输出 更新日期
hunyuan-vision-1.5-instruct Tencent Hunyuan Vision 1.5 Instruct 视觉识别 ¥0.0031 ¥0.0091 2025-12-18 ❇️最近更新
hunyuan-2.0-instruct-20251111 Hunyuan 2.0 instruct 20251111 文本生成 ¥0.0009 ¥0.0021 2025-12-01
hunyuan-2.0-thinking-20251109 Hunyuan 2.0 thinking 20251109 文本生成、深度思考 ¥0.0011 ¥0.0041 2025-12-01
tencent/hunyuan-a13b-instruct Hunyuan A13B Instruct 文本生成 ¥0.0019 ¥0.0075 2025-07-09
hunyuan-a13b Hunyuan a13b 文本生成 ¥0.0006 ¥0.0025 2025-06-26
hunyuan-t1-vision Hunyuan-T1-Vision 视觉深度思考大模型 图片理解、深度思考 ¥0.0035 ¥0.0102 2025-06-19
hunyuan-turbos-vision-20250619 Hunyuan Turbos Vision 20250619 图片识别 ¥0.0035 ¥0.0102 2025-06-19

🚀 messages | ✅️必填 | array | 由历史对话组成的消息列表。array 中的每个元素形式通常为 {"role": 角色, "content": 内容}。角色当前可选值为:systemuserassistant

messages[0]中支持 rolesystem

一般情况下,userassistant 需要交替出现,且 messages 中最后一个元素的 roleuser


🚀 stream | 选填 | boolean | 默认值 false | 是否流式输出。

false(默认值):模型生成完所有内容后一次性返回结果。

true:返回符合 SSE 协议的响应,边生成边输出,即每生成一部分内容就立即输出一个片段(chunk),最后以一条 data: [DONE] 消息结束。


🚀 max_tokens | 选填 | int | 允许模型生成的最大 tokens 数。

应用场景:max_tokens 参数适用于需要限制字数(如生成摘要、关键词)、控制成本或减少响应时间的场景。


🚀 temperature | 选填 | float | 采样温度,用于控制模型生成文本的多样性。取值范围:[0.0, 2.0]。较高的数值会使输出更加多样化和不可预测,而较低的数值会使其更加集中和确定。


🚀 top_p | 选填 | float | 核采样概率阈值,用于控制模型生成文本的多样性。取值区间为 [0.0, 1.0]。取值越大,生成文本的多样性越强。

由于 temperature 与 top_p 均可以控制生成文本的多样性,因此建议您只设置其中一个值。


返回参数

不同模型返回参数可能存在差异,请以实际返回为准。

返回参数 数据类型 说明
id string 系统生成的标识本次调用的id。
model string 本次调用的模型名。
choices array 模型生成内容的详情。
choices[i].finish_reason string 结束标志。
choices[i].message object 模型生成的消息。
choices[i].message.role string 生成消息的角色。
choices[i].message.content string 生成消息的内容。
choices[i].index int 生成的结果序列编号。
created int 请求被创建时的时间戳。
usage object 请求所消耗的 tokens 数据。
usage.prompt_tokens int 用户输入转换成 token 后的数量。
usage.completion_tokens int 模型生成回复转换为 token 后的数量。
usage.total_tokens int prompt_tokens 与 completion_tokens 的总和。

响应头(Response Headers)

Header 说明 示例 相关链接
X-Account-Balance API_KEY 余额(元) 123.0123 API_KEY 费用充值入口:https://wcode.net/apikey-recharge

Python 代码示例(Requests,hunyuan-standard)

import requests
import json

url = "https://wcode.net/api/gpt/v1/chat/completions"

payload = json.dumps({
  "model": "hunyuan-standard",
  "messages": [
    {
      "role": "system",
      "content": "You are a helpful assistant."
    },
    {
      "role": "user",
      "content": "你好"
    }
  ]
})

headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer API_KEY'     # TODO: 这里的 API_KEY 需要替换,获取 API_KEY 入口:https://wcode.net/get-apikey
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

Java 代码示例(OkHttp,hunyuan-standard)

OkHttpClient client = new OkHttpClient().newBuilder().build();

MediaType mediaType = MediaType.parse("application/json");

RequestBody body = RequestBody.create(mediaType, "{\"model\":\"hunyuan-standard\",\"messages\":[{\"role\":\"system\",\"content\":\"You are a helpful assistant.\"},{\"role\":\"user\",\"content\":\"你好\"}]}");

Request request = new Request.Builder()
  .url("https://wcode.net/api/gpt/v1/chat/completions")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "Bearer API_KEY")     // TODO: 这里的 API_KEY 需要替换,获取 API_KEY 入口:https://wcode.net/get-apikey
  .build();

Response response = client.newCall(request).execute();

PHP 代码示例(Guzzle,hunyuan-standard)

<?php

$client = new Client();

$headers = [
  'Content-Type' => 'application/json',
  'Authorization' => 'Bearer API_KEY'     // TODO: 这里的 API_KEY 需要替换,获取 API_KEY 入口:https://wcode.net/get-apikey
];

$body = '{
  "model": "hunyuan-standard",
  "messages": [
    {
      "role": "system",
      "content": "You are a helpful assistant."
    },
    {
      "role": "user",
      "content": "你好"
    }
  ]
}';

$request = new Request('POST', 'https://wcode.net/api/gpt/v1/chat/completions', $headers, $body);

$res = $client->sendAsync($request)->wait();

echo $res->getBody();

...其他编程语言可参考下方 curl http 请求示例进行调用

请求示例 1(hunyuan-standard)

curl --request POST 'https://wcode.net/api/gpt/v1/chat/completions' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer API_KEY' \
--data '{
    "model": "hunyuan-standard",
    "messages": [
        {
            "role": "system",
            "content": "You are a helpful assistant."
        },
        {
            "role": "user",
            "content": "你好"
        }
    ]
}'

响应示例 1(hunyuan-standard)

{
    "id": "a16253ff29ec0cf30d2b23b9cf10c302",
    "object": "chat.completion",
    "created": 1737186705,
    "model": "hunyuan-standard",
    "system_fingerprint": "",
    "choices": [
        {
            "index": 0,
            "message": {
                "role": "assistant",
                "content": "您好!非常高兴与您交流,今天有什么有趣的事情想和我分享呢😄"
            },
            "finish_reason": "stop"
        }
    ],
    "usage": {
        "prompt_tokens": 11,
        "completion_tokens": 18,
        "total_tokens": 29
    }
}

请求示例 1.1(多轮对话,hunyuan-standard)

curl --request POST 'https://wcode.net/api/gpt/v1/chat/completions' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer API_KEY' \
--data '{
    "model": "hunyuan-standard",
    "messages": [
        {
            "role": "system",
            "content": "You are a helpful assistant."
        },
        {
            "role": "user",
            "content": "你好"
        },
        {
            "role": "assistant",
            "content": "你好!有什么可以帮助你的吗?"
        },
        {
            "role": "user",
            "content": "什么是AGI?"
        }
    ]
}'

响应示例 1.1(多轮对话,hunyuan-standard)

{
    "id": "ac7edb2d915d6c462241f514f1c554c0",
    "object": "chat.completion",
    "created": 1737186755,
    "model": "hunyuan-standard",
    "system_fingerprint": "",
    "choices": [
        {
            "index": 0,
            "message": {
                "role": "assistant",
                "content": "AGI,全称Artificial General Intelligence,即通用人工智能,是指一种具备与人类同等或超越人类智慧水平的AI系统。这种系统能够像人类一样在各种不同的领域和任务中展现出智能行为,并具备广泛的认知能力。以下是关于AGI的详细介绍:\n\n### AGI的定义\n\n- **与人类智能的对比**:AGI的核心在于“通用”二字,它不是针对特定任务设计的,而是能够像人类一样处理各种各样的问题,展现出类似于人类的智能水平,包括学习、推理、解决问题、感知、理解自然语言、创造、拥有情感和社会认知等。\n- **与弱人工智能(ANI)的区别**:与当前专注于特定任务的弱人工智能不同,AGI能够在不同的领域和任务中灵活运用其智能,无需针对每个任务进行专门的训练或编程。\n\n### AGI的实现途径\n\n目前,实现AGI还没有明确的路径,但以下是一些主流的研究方向:\n\n- **符号主义**:认为智能可以通过符号操作和逻辑推理来实现。\n- **连接主义**:认为智能源于大量神经元之间的连接和相互作用。\n- **行为主义**:认为智能体现在与环境的交互中,通过试错和强化学习来获得智能。\n- **混合方法**:结合多种方法的优点。\n- **神经形态计算**:模仿人脑的结构和功能,构建新型的计算架构。\n- **发育式/进化式方法**:模拟人类的认知发展过程或生物进化过程,让AI系统逐步发展出通用智能。\n\n### AGI的能力与潜在应用\n\n- **能力**:强大的学习和推理能力、广泛的知识和常识、创造力和创新能力、自适应和自我改进能力。\n- **潜在应用**:科学研究、医疗健康、教育、经济、交通、金融、艺术与娱乐等[1](@ref。\n"
            },
            "finish_reason": "stop"
        }
    ],
    "usage": {
        "prompt_tokens": 29,
        "completion_tokens": 401,
        "total_tokens": 430
    }
}

请求示例 2(hunyuan-standard,流式输出)

curl --request POST 'https://wcode.net/api/gpt/v1/chat/completions' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer API_KEY' \
--data '{
    "model": "hunyuan-standard",
    "stream": true,
    "messages": [
        {
            "role": "system",
            "content": "You are a helpful assistant."
        },
        {
            "role": "user",
            "content": "你好"
        }
    ]
}'

响应示例 2(hunyuan-standard,流式输出)

data: {"id":"24df7faf10422bb8d3ea05fe74e3030a","object":"chat.completion.chunk","created":1737186811,"model":"hunyuan-standard","choices":[{"index":0,"delta":{"role":"assistant","content":"您好"},"finish_reason":null}]}

data: {"id":"24df7faf10422bb8d3ea05fe74e3030a","object":"chat.completion.chunk","created":1737186811,"model":"hunyuan-standard","choices":[{"index":0,"delta":{"role":"assistant","content":"!"},"finish_reason":null}]}

data: {"id":"24df7faf10422bb8d3ea05fe74e3030a","object":"chat.completion.chunk","created":1737186811,"model":"hunyuan-standard","choices":[{"index":0,"delta":{"role":"assistant","content":"非常"},"finish_reason":null}]}

data: {"id":"24df7faf10422bb8d3ea05fe74e3030a","object":"chat.completion.chunk","created":1737186811,"model":"hunyuan-standard","choices":[{"index":0,"delta":{"role":"assistant","content":"高兴"},"finish_reason":null}]}

data: {"id":"24df7faf10422bb8d3ea05fe74e3030a","object":"chat.completion.chunk","created":1737186811,"model":"hunyuan-standard","choices":[{"index":0,"delta":{"role":"assistant","content":"与您"},"finish_reason":null}]}

data: {"id":"24df7faf10422bb8d3ea05fe74e3030a","object":"chat.completion.chunk","created":1737186811,"model":"hunyuan-standard","choices":[{"index":0,"delta":{"role":"assistant","content":"交流"},"finish_reason":null}]}

data: {"id":"24df7faf10422bb8d3ea05fe74e3030a","object":"chat.completion.chunk","created":1737186811,"model":"hunyuan-standard","choices":[{"index":0,"delta":{"role":"assistant","content":","},"finish_reason":null}]}

data: {"id":"24df7faf10422bb8d3ea05fe74e3030a","object":"chat.completion.chunk","created":1737186811,"model":"hunyuan-standard","choices":[{"index":0,"delta":{"role":"assistant","content":"今天"},"finish_reason":null}]}

data: {"id":"24df7faf10422bb8d3ea05fe74e3030a","object":"chat.completion.chunk","created":1737186811,"model":"hunyuan-standard","choices":[{"index":0,"delta":{"role":"assistant","content":"有什么"},"finish_reason":null}]}

data: {"id":"24df7faf10422bb8d3ea05fe74e3030a","object":"chat.completion.chunk","created":1737186811,"model":"hunyuan-standard","choices":[{"index":0,"delta":{"role":"assistant","content":"有趣"},"finish_reason":null}]}

data: {"id":"24df7faf10422bb8d3ea05fe74e3030a","object":"chat.completion.chunk","created":1737186811,"model":"hunyuan-standard","choices":[{"index":0,"delta":{"role":"assistant","content":"的事情"},"finish_reason":null}]}

data: {"id":"24df7faf10422bb8d3ea05fe74e3030a","object":"chat.completion.chunk","created":1737186811,"model":"hunyuan-standard","choices":[{"index":0,"delta":{"role":"assistant","content":"想"},"finish_reason":null}]}

data: {"id":"24df7faf10422bb8d3ea05fe74e3030a","object":"chat.completion.chunk","created":1737186811,"model":"hunyuan-standard","choices":[{"index":0,"delta":{"role":"assistant","content":"和我"},"finish_reason":null}]}

data: {"id":"24df7faf10422bb8d3ea05fe74e3030a","object":"chat.completion.chunk","created":1737186811,"model":"hunyuan-standard","choices":[{"index":0,"delta":{"role":"assistant","content":"分享"},"finish_reason":null}]}

data: {"id":"24df7faf10422bb8d3ea05fe74e3030a","object":"chat.completion.chunk","created":1737186811,"model":"hunyuan-standard","choices":[{"index":0,"delta":{"role":"assistant","content":"呢"},"finish_reason":null}]}

data: {"id":"24df7faf10422bb8d3ea05fe74e3030a","object":"chat.completion.chunk","created":1737186811,"model":"hunyuan-standard","choices":[{"index":0,"delta":{"role":"assistant","content":"😄"},"finish_reason":null}]}

data: {"id":"24df7faf10422bb8d3ea05fe74e3030a","object":"chat.completion.chunk","created":1737186811,"model":"hunyuan-standard","choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":"stop"}]}

data: {"id":"24df7faf10422bb8d3ea05fe74e3030a","object":"chat.completion.chunk","created":1737186811,"model":"hunyuan-standard","choices":[],"usage":{"prompt_tokens":11,"completion_tokens":18,"total_tokens":29}}

data: [DONE]

异常响应示例

{
    "error": {
        "message": "Invalid API-KEY",
        "type": "invalid_request_error",
        "param": null,
        "code": null
    }
}



以上文档为标准版 API 接口文档,可直接用于项目开发和系统调用。如果标准版 API 接口无法满足您的需求,需要定制开发 API 接口,请扫码联系我们的 IT 技术支持工程师:

(沟通需求✅ → 确认技术方案✅ → 沟通费用与工期✅ → 开发&测试✅ → 验收交付✅ → 维护升级✅)

最受关注模型

GLM 4.7

文本生成、深度思考

MiniMax M2.1

文本生成、深度思考

Doubao Seed 2.0 Code

代码补全、深度思考

GLM 5

文本生成、深度思考、代码补全

Qwen3 Coder Next

文本生成、深度思考、代码补全

Step 3.5 Flash

文本生成、代码补全、深度思考

Qwen3.5 27B

深度思考、视觉理解、文本生成

Qwen3.5 35B A3B

深度思考、视觉理解、文本生成

Doubao Seed 1.8

多模态、深度思考

Qwen3.5 397B A17B

文本生成、深度思考、多模态

最新发布模型

Qwen3.5 9B

文本生成、多模态

Qwen3.5 35B A3B

深度思考、视觉理解、文本生成

Qwen3.5 27B

深度思考、视觉理解、文本生成

Qwen3.5 Flash

深度思考

Qwen3.5 122B A10B

深度思考、视觉理解、文本生成

Qwen3.5 397B A17B

文本生成、深度思考、多模态

Doubao Seed 2.0 Mini

文本生成、深度思考、多模态

Doubao Seed 2.0 Code

代码补全、深度思考

Qwen 3.5 Plus

文本生成、深度思考、多模态

Doubao Seed 2.0 Pro

文本生成、深度思考、多模态