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

# 腾讯混元对话 API

> 腾讯混元对话模型（以 Hy4 Preview 为代表）通过 VibeToken 提供，兼容 OpenAI 的对话补全接口，支持推理与工具调用。

## 概述

腾讯混元对话模型现已上线 VibeToken，通过标准的兼容 OpenAI 的对话补全接口提供服务，支持流式输出与工具调用。**Hy4 Preview** 是一款大规模混合专家（MoE）推理模型，面向编程 Agent、复杂工具调用和长链路多步骤任务，拥有 100 万 token 上下文窗口。

| | |
| - | - |
| **提供方** | Tencent |
| **模型系列** | `hy4` |
| **模态** | 对话 |
| **输入** | 文本 |
| **输出** | 文本 |

## 模型

| 模型 ID | 上下文窗口 | 最大输出 token | 输入 |
| - | - | - | - |
| `tencent/hy4-preview` | 1,000,000 | 64,000 | 文本 |

本页不再列出价格。费率按模型配置在 VibeToken 目录中,并且可以按账号单独覆盖,
任何抄写到文档里的数字都会在下一次调价后失效。请通过 [Models API](https://docs.vibetoken.cn/zh/api-reference/models.md)
获取任一模型的实时费率:

```http theme={null}
GET /api/models/{model}/pricing
```

模型 ID 中的斜杠需要 URL 编码 —— 例如 `tencent%2Fhy4-preview`。
按 token 计费：输入与输出 token 按该模型的费率计费，推理 token 计入输出。

## 接口端点

```http theme={null}
POST https://vibetoken.cn/v1/chat/completions
```

与 OpenAI 的[对话补全 API](https://platform.openai.com/docs/api-reference/chat) 无缝兼容 ——
只需将你现有的 OpenAI 客户端指向 `https://vibetoken.cn/v1`，并使用你的
VibeToken 密钥即可。所有支持的参数详见完整的[对话补全参考文档](https://docs.vibetoken.cn/zh/api-reference/chat-completions.md)。

## 快速开始

```bash cURL theme={null}
curl https://vibetoken.cn/v1/chat/completions \
  -H "Authorization: Bearer $VIBETOKEN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "tencent/hy4-preview",
    "messages": [
      { "role": "user", "content": "Explain mixture-of-experts in one sentence." }
    ]
  }'
```

```python Python theme={null}
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://vibetoken.cn/v1",
    api_key=os.environ["VIBETOKEN_API_KEY"],
)

resp = client.chat.completions.create(
    model="tencent/hy4-preview",
    messages=[{"role": "user", "content": "Hello!"}],
)
print(resp.choices[0].message.content)
```

```javascript Node.js theme={null}
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://vibetoken.cn/v1",
  apiKey: process.env.VIBETOKEN_API_KEY,
});

const resp = await client.chat.completions.create({
  model: "tencent/hy4-preview",
  messages: [{ role: "user", content: "Hello!" }],
});
console.log(resp.choices[0].message.content);
```

设置 `"stream": true` 即可启用 token 流式输出（Server-Sent Events），与 OpenAI API 完全一致。`temperature` 与 `top_p` 照常可用。

## 推理

Hy4 Preview 会先思考再作答。推理过程通过 `choices[].message.reasoning_content` 返回（流式时为 `delta.reasoning_content`），与 `content` 中的最终回答分开。推理 token 按输出计费，请在 `max_tokens` 中为其预留空间。两类输出的返回与计费方式详见[推理模型](https://docs.vibetoken.cn/zh/api-reference/chat-completions.md#推理模型)。

## 工具调用

传入 OpenAI 风格的 `tools` 即可。`tool_choice` 支持 `"auto"`（默认），也支持指定具体函数（`{"type": "function", "function": {"name": "get_weather"}}`）以强制调用某个工具。

## 结构化输出

Hy4 Preview 支持通过 JSON Schema 指定 `response_format`：

```json theme={null}
{
  "model": "tencent/hy4-preview",
  "messages": [{ "role": "user", "content": "Name a city and its country." }],
  "response_format": {
    "type": "json_schema",
    "json_schema": {
      "name": "city",
      "strict": true,
      "schema": {
        "type": "object",
        "properties": {
          "city": { "type": "string" },
          "country": { "type": "string" }
        },
        "required": ["city", "country"],
        "additionalProperties": false
      }
    }
  }
}
```

**不支持**普通 JSON 模式（`{"type": "json_object"}`），模型会拒绝该请求。需要返回 JSON 时，请改用 `json_schema`（即便是一个宽松的 schema）。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.