hy4
混元 hy4
以下说明使用 hy4 调用 FoxRouter 的兼容接口。价格与分组在构建文档时同步自 foxrouter.org/pricing,实际账户分组和可用性以控制台为准。
#计费信息
原价
- 输入
- ¥6 / 百万 Token
- 输出
- ¥18 / 百万 Token
- 缓存读取
- ¥0.3 / 百万 Token
各分组价格单位:¥ / 百万 Token,按原价 × 分组倍率
| 分组 | 输入 | 输出 | 缓存读取 |
|---|---|---|---|
| default分组×1默认分组 | ¥6 | ¥18 | ¥0.3 |
| 国模svip分组(0.06x)×0.1国内模型就选这个分组(deepseek、glm等),比较稳定 | ¥0.6 | ¥1.8 | ¥0.03 |
| 国模特惠分组×0.04国内模型特惠,稳定性相对于svip分组会差一些 | ¥0.24 | ¥0.72 | ¥0.012 |
价格与分组同步于 2026-11-01.
#Chat Completions
POST
https://foxrouter.org/v1/chat/completions根据对话历史创建模型响应。支持流式和非流式响应。
兼容 OpenAI Chat Completions API。
#认证
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
Authorization | Bearer <token> | 是 | 使用 Bearer Token 认证。 格式: Authorization: Bearer sk-xxxxxx In: header |
#请求示例
curl -X POST "https://foxrouter.org/v1/chat/completions" \
-H "Authorization: Bearer $FOXROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "hy4",
"messages": [
{
"role": "system",
"content": "string"
}
]
}'import os
import requests
url = "https://foxrouter.org/v1/chat/completions"
headers = {
"Authorization": "Bearer " + os.environ["FOXROUTER_API_KEY"],
"Content-Type": "application/json",
}
payload = """{
"model": "hy4",
"messages": [
{
"role": "system",
"content": "string"
}
]
}"""
response = requests.post(url, headers=headers, data=payload)
print(response.status_code)
print(response.text)const payload = {
"model": "hy4",
"messages": [
{
"role": "system",
"content": "string"
}
]
};
const response = await fetch("https://foxrouter.org/v1/chat/completions", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.FOXROUTER_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify(payload),
});
console.log(response.status, await response.text());import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
String payload = """
{
"model": "hy4",
"messages": [
{
"role": "system",
"content": "string"
}
]
}
""";
HttpRequest.Builder builder = HttpRequest.newBuilder()
.uri(URI.create("https://foxrouter.org/v1/chat/completions"))
.header("Authorization", "Bearer " + System.getenv("FOXROUTER_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString(payload))
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(builder.build(), HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode());
System.out.println(response.body());
}
}#请求体
application/json
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 模型 ID |
messages | array<object> | 是 | 对话消息列表 |
temperature | number | 否 | 采样温度 · 默认: 1 · 范围: 0 <= value <= 2 |
top_p | number | 否 | 核采样参数 · 默认: 1 · 范围: 0 <= value <= 1 |
n | integer | 否 | 生成数量 · 默认: 1 · 范围: 1 <= value |
stream | boolean | 否 | 是否流式响应 · 默认: false |
stream_options | object | 否 | |
stop | string|array<string> | 否 | 停止序列 |
max_tokens | integer | 否 | 最大生成 Token 数 |
max_completion_tokens | integer | 否 | 最大补全 Token 数 |
presence_penalty | number | 否 | 默认: 0 · 范围: -2 <= value <= 2 |
frequency_penalty | number | 否 | 默认: 0 · 范围: -2 <= value <= 2 |
logit_bias | object | 否 | |
user | string | 否 | |
tools | array<object> | 否 | |
tool_choice | string|object | 否 | |
response_format | object | 否 | |
seed | integer | 否 | |
reasoning_effort | string | 否 | 推理强度 (用于支持推理的模型) · 可选值: "low" | "medium" | "high" |
modalities | array<string> | 否 | |
audio | object | 否 |
#响应体
这篇文档对您有帮助吗?
最后更新于 2026/9/11
Gemini文本聊天 POST
上一页
Responses格式 POST
下一页
#200 成功 · application/json
{
"id": "string",
"object": "chat.completion",
"created": 0,
"model": "hy4",
"choices": [
{
"index": 0,
"message": {
"role": "system",
"content": "string",
"name": "string",
"tool_calls": [
{
"id": "string",
"type": "function",
"function": {
"name": "string",
"arguments": "string"
}
}
],
"tool_call_id": "string",
"reasoning_content": "string"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 0,
"completion_tokens": 0,
"total_tokens": 0,
"prompt_tokens_details": {
"cached_tokens": 0,
"text_tokens": 0,
"audio_tokens": 0,
"image_tokens": 0
},
"completion_tokens_details": {
"text_tokens": 0,
"audio_tokens": 0,
"reasoning_tokens": 0
}
},
"system_fingerprint": "string"
}#400 请求错误 · application/json
{
"error": {
"message": "string",
"type": "string",
"param": "string",
"code": "string"
}
}#429 请求过多 · application/json
{
"error": {
"message": "string",
"type": "string",
"param": "string",
"code": "string"
}
}#在线调用
curl -X POST "https://foxrouter.org/v1/chat/completions" \
-H "Authorization: Bearer $FOXROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "hy4",
"messages": [
{
"role": "user",
"content": "你好,请用一句话介绍你自己。"
}
],
"max_tokens": 256
}'import os
import requests
url = "https://foxrouter.org/v1/chat/completions"
headers = {
"Authorization": "Bearer " + os.environ["FOXROUTER_API_KEY"],
"Content-Type": "application/json",
}
payload = """{
"model": "hy4",
"messages": [
{
"role": "user",
"content": "你好,请用一句话介绍你自己。"
}
],
"max_tokens": 256
}"""
response = requests.post(url, headers=headers, data=payload)
print(response.status_code)
print(response.text)const payload = {
"model": "hy4",
"messages": [
{
"role": "user",
"content": "你好,请用一句话介绍你自己。"
}
],
"max_tokens": 256
};
const response = await fetch("https://foxrouter.org/v1/chat/completions", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.FOXROUTER_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify(payload),
});
console.log(response.status, await response.text());import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
String payload = """
{
"model": "hy4",
"messages": [
{
"role": "user",
"content": "你好,请用一句话介绍你自己。"
}
],
"max_tokens": 256
}
""";
HttpRequest.Builder builder = HttpRequest.newBuilder()
.uri(URI.create("https://foxrouter.org/v1/chat/completions"))
.header("Authorization", "Bearer " + System.getenv("FOXROUTER_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString(payload))
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(builder.build(), HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode());
System.out.println(response.body());
}
}