产品文档

Tengri 大模型

更新于 2026-12-03

Tengri 系列大模型对话接口,兼容 OpenAI 与 Anthropic 协议,支持流式输出与图片、音频、视频多模态理解。

能力与用法

受信任机构准入与白名单说明

依据《生成式人工智能服务管理暂行办法》及相关法律法规要求,Tengri AI 处于生成式人工智能服务合规备案阶段,仅面向已完成企业、高等院校或科研机构主体认证并经审核通过的合作伙伴与研究团队开放合作接入。接入流程共两步:

  1. 在控制台「设置 → 实名与机构认证」完成个人实名认证与机构主体认证;
  2. 前往「Tengri AI 接入」提交受信任机构准入申请,或直接为指定密钥提交密钥白名单申请(支持绑定指定模型清单与最多 50 条出口 IP / CIDR 网段)。
Tengri AI 合作接入与密钥白名单申请页:查看主体认证审核进度并配置白名单密钥

Tengri 大模型系列面向传统蒙古文、西里尔蒙古文、藏文、维吾尔文、哈萨克文与中英文进行了专项训练与评测,提供多轮对话、SSE 流式输出、函数工具调用(Function Calling)、结构化 JSON Schema 输出,以及图片、音频、视频与 PDF 文档多模态理解能力。

模型广场与在线调试:实时调试 Tengri 大模型、观察流式响应与 Token 消耗

1. 协议兼容矩阵与服务基址

全部兼容协议共用同一云账户余额与控制台 API Key(sk-heimori-...),现有 SDK 仅需替换 base_url 与 api_key 即可切换:

协议家族Base URL鉴权方式完整规范文档
OpenAI Chat Completionshttps://cloud.heimori.cn/v1Authorization: Bearer <KEY> 或 api-key: <KEY>本页下方完整参数、响应与代码示例
OpenAI Responses APIhttps://cloud.heimori.cn/v1Authorization: Bearer <KEY> 或 api-key: <KEY>Responses API 协议指南
Anthropic Messageshttps://cloud.heimori.cnx-api-key: <KEY> 或 Authorization: Bearer <KEY>(推荐附 anthropic-version: 2023-06-01)Anthropic Messages 协议指南
传统补全、DashScope 与账单兼容https://cloud.heimori.cn/v1 或 /compatible-mode/v1Authorization: Bearer <KEY>传统补全、DashScope 与账单兼容端点

语音合成与语音转写请分别使用平台专项能力 Heimori-TTS(POST /v1/tts)与 语音识别(POST /v1/asr/transcriptions / WSS /v1/asr/realtime)。

2. 模型清单与选型指南

模型名称定位与适用场景推荐特性
tengri-2-max旗舰档,适合复杂长文档分析、高质量多语种创作与深度研究长上下文、复杂指令遵循、全模态理解
tengri-2标准主力档,传统/西里尔蒙古文与多民族语种综合能力均衡通用对话、翻译改写、工具调用、结构化输出
tengri-2-fast高速低延迟档,面向高并发客服、实时补全与批量信息抽取极速首字延迟、高吞吐、低成本
tengri-2-pro专业分析档,适合长文精编、代码生成与多步逻辑分析强逻辑分析、高准确度 JSON Schema 遵循
tengri-t1T1 轻量系列,适合日常问答、摘要与高吞吐常规任务稳定吞吐、轻量接入
tengri-t1-proT1 专业系列,适合需要更高理解准确度的常规业务任务稳健准确、轻量接入

当前已上架模型清单与实时单价以定价页及 GET /v1/models 返回结果为准。

端点列表

方法路径说明
POST/v1/chat/completions对话补全(OpenAI 兼容,支持流式 SSE、函数调用、结构化输出与多模态输入)
POST/v1/responses模型响应(OpenAI Responses API 兼容,支持多模态条目、工具调用与结构化输出)
POST/v1/responses/input_tokens估算 Responses 输入 Token 数(不计费)
POST/v1/messages对话消息(Anthropic Messages 兼容,支持 Anthropic SDK 与 Claude Code)
POST/v1/messages/count_tokens统计 Anthropic 消息输入 Token 数(不计费)
POST/v1/completions文本续写(Legacy Completions 兼容)
GET/v1/models查询当前密钥可用的模型列表(同时支持 chat 与 embedding 权限密钥,不计费)
GET/v1/models/{model}查询单个模型元数据(同时支持 chat 与 embedding 权限密钥,不计费)
POST/compatible-mode/v1/chat/completionsDashScope 兼容前缀对话补全
GET/compatible-mode/v1/modelsDashScope 兼容前缀模型列表查询(不计费)
GET/v1/dashboard/billing/subscription查询账户余额与额度上限(OpenAI Billing 兼容,不计费)
GET/v1/dashboard/billing/usage按日期区间查询当前密钥累计消费金额(OpenAI Billing 兼容,不计费)
GET/v1/dashboard/billing/credit_grants查询可用额度与余额快照(OpenAI Billing 兼容,不计费)

完整参数、响应示例与多语言代码见本页下方「API 参考」。

参数与规格

协议家族与专页文档

协议与专题覆盖端点文档入口
OpenAI Chat Completions(本页)POST /v1/chat/completions、GET /v1/models、GET /v1/models/{model}本页完整覆盖全部请求参数、多模态内容块、非流式与 SSE 响应结构及多语言示例
OpenAI Responses APIPOST /v1/responses、POST /v1/responses/input_tokens详见 Responses API 协议指南
Anthropic MessagesPOST /v1/messages、POST /v1/messages/count_tokens详见 Anthropic Messages 协议指南(含 Claude Code / Cursor 配置)
传统补全、DashScope 与账单兼容/v1/completions、/compatible-mode/v1/*、/v1/dashboard/billing/*详见 传统补全、DashScope 与账单兼容端点

POST /v1/chat/completions 请求参数

参数类型必填说明
modelstring必填目标模型名称(如 tengri-2、tengri-2-max、tengri-2-fast),实时可用清单见 GET /v1/models
messagesobject[]必填按时间顺序排列的对话消息列表(长度 ≥ 1),多轮对话由调用方携带历史上下文;角色与多模态内容块结构见下表
streamboolean可选设为 true 时响应 Content-Type: text/event-stream,按 SSE 推送 chat.completion.chunk,末尾输出 data: [DONE]默认值false
stream_optionsobject可选仅 stream: true 时生效的流式选项对象
└include_usageboolean可选设为 true 时在 [DONE] 前追加一帧含完整 usage 的数据块默认值false
max_completion_tokensinteger可选限制单次回复的最大输出 token 上限(≥ 1,含深度推理消耗);与 max_tokens 同时传入时以本字段为准
max_tokensinteger可选限制单次回复的最大输出 token 上限(≥ 1);与 max_completion_tokens 同时传入时优先采用后者
temperaturenumber可选采样温度(0.0 ~ 2.0),值越低输出越确定;事实问答与信息抽取建议 0.0 ~ 0.3,创意写作建议 0.7 ~ 1.0;建议与 top_p 二选一调节
top_pnumber可选核采样累计概率阈值(0.0 ~ 1.0,如 0.9 仅在累计概率前 90% 的候选词内采样)
ninteger可选单次请求生成的候选回复条数(≥ 1),返回结果放入 choices[0..n-1];输入 token 仅计一次,输出按全部候选合计默认值1
stopstring | string[]可选停止词序列(单个字符串或最多 4 项数组),模型生成命中任一项时立刻停止输出(停止词本身默认不包含在返回文本中)
presence_penaltynumber可选话题存在惩罚(-2.0 ~ 2.0),正值鼓励引入尚未出现的新话题与词汇默认值0
frequency_penaltynumber可选词频重复惩罚(-2.0 ~ 2.0),正值按已出现次数降低重复词汇的生成概率默认值0
logit_biasRecord<string, number>可选按 token ID 映射采样偏置(值域 -100 ~ 100,-100 强抑制,100 强倾向),具体生效范围视目标模型而定
seedinteger可选有符号整数随机种子,相同请求参数下尽可能提高输出可复现性
toolsobject[]可选Function Calling 工具定义数组
└typestring必填工具类型可选值function默认
└functionobject必填函数描述对象,含 name(必填)、可选 description、parameters(标准 JSON Schema)与 strict(布尔)
tool_choicestring | object可选工具选择策略:auto 由模型自主决定、none 禁止调用、required 必须调用任一工具,或传 { "type": "function", "function": { "name": "fn_name" } } 强制指定函数(仅在传入 tools 时默认 auto)可选值auto默认nonerequired
parallel_tool_callsboolean可选设为 true 时允许模型在单轮回复中并行返回多个 tool_calls;设为 false 强制单轮最多发起一个工具调用默认值true
response_formatobject可选输出格式约束:{ "type": "text" }、{ "type": "json_object" }(需在提示词中要求输出 JSON)或 { "type": "json_schema", "json_schema": { "name": "...", "description"?: "...", "schema": {...}, "strict"?: true } }可选值text默认json_objectjson_schema
userstring可选调用方终端用户标识,便于业务侧风控统计与排障定位
metadataRecord<string, string>可选附加业务自定义字符串键值元数据

messages 消息角色与多模态内容块

角色 / 内容块 typeJSON 结构适用场景与格式约束
角色 system{ "role": "system", "content": "你是专业蒙汉双语助手" }系统级提示词,用于设定角色、领域规范与输出格式;content 可为字符串或 text 内容块数组
角色 developer{ "role": "developer", "content": "严格按 JSON 返回" }开发者指令,与 system 同级合并生效,兼容新版 OpenAI SDK 规范
角色 user{ "role": "user", "content": "..." } 或内容块数组用户输入消息;纯文本直接传字符串,含图片、音频、视频或文档时传内容块数组
角色 assistant{ "role": "assistant", "content": "...", "tool_calls"?: [...] }历史助手回复;当该轮仅发起工具调用时 content 可为 null 并携带 tool_calls 数组
角色 tool{ "role": "tool", "tool_call_id": "call_...", "name"?: "...", "content": "..." }工具执行结果回传,须紧随对应 assistant.tool_calls 之后;tool_call_id 必须与模型返回的 tool_calls[].id 精确匹配
内容块 text{ "type": "text", "text": "请总结这份文档" }多模态消息中的文本指令或上下文片段
内容块 image_url{ "type": "image_url", "image_url": { "url": "https://... 或 data:image/jpeg;base64,...", "detail"?: "auto" } }图片理解,支持公网可访问 HTTPS URL 或 Base64 Data URI(单次请求体总上限 200 MB)图片格式JPEGPNGWebPGIF可选值auto默认lowhigh
内容块 input_audio{ "type": "input_audio", "input_audio": { "data": "<base64>", "format": "mp3" } }音频内容理解,传入标准 Base64 编码音频数据与格式标识音频格式mp3wav
内容块 input_video{ "type": "input_video", "input_video": { "data": "<base64>", "format": "mp4" } }视频内容理解,传入标准 Base64 编码视频数据与格式标识视频格式mp4
内容块 file{ "type": "file", "file": { "filename": "report.pdf", "file_data": "data:application/pdf;base64,..." } }文档与媒体附件输入,支持 PDF(application/pdf)、音频与视频 Base64 Data URI(单次请求体总上限 200 MB)

非流式响应字段(chat.completion)

字段类型说明
idstring本次对话补全的唯一响应 ID(如 chatcmpl-20261128001)
objectstring固定为 chat.completion
createdinteger响应创建时的 Unix 秒级时间戳
modelstring实际响应所对应的模型名(与请求参数 model 一致)
system_fingerprintstring可选;模型运行配置指纹(部分模型返回)
choicesobject[]候选回复数组,条目数由请求参数 n 决定(默认 1 条)
└indexinteger候选序号,从 0 开始递增
└messageobject助手消息对象
└rolestring固定为 assistant
└contentstring | null助手回复文本内容;仅发起函数工具调用时可能为 null;输出触发内容安全过滤时为空字符串 ""
└tool_callsobject[]可选;模型请求调用的函数列表,每项含 id、type: "function"、function: { name, arguments }(arguments 为 JSON 序列化字符串)
└finish_reasonstring生成终止原因:stop 正常结束或命中停止词,length 达到最大输出 token 上限,tool_calls 等待回传工具执行结果,content_filter 触发输出内容安全审核并终止可选值stoplengthtool_callscontent_filter
usageobject本次请求的 token 用量统计
└prompt_tokensinteger输入上下文消耗的 token 数(含系统提示词、历史消息、工具定义与多模态媒体折算)
└completion_tokensinteger输出生成的 token 数(深度推理模型包含内部推理消耗)
└total_tokensinteger本次请求总 token 数(prompt_tokens + completion_tokens)
└prompt_tokens_detailsobject可选;输入 token 细分对象,命中提示词缓存时包含 cached_tokens(整数)

流式响应字段(SSE chat.completion.chunk)

帧类型 / 字段类型或格式说明
SSE 帧语法text/event-stream每条数据帧以 data: <JSON>\n\n 格式推送,双换行分隔
流结束标志data: [DONE]所有内容增量块与末尾用量块推送完毕后输出,标识当前 SSE 流关闭
objectstring固定为 chat.completion.chunk
choicesobject[]流式增量候选数组(末尾独立用量帧时为空数组 [])
└indexinteger候选序号,从 0 开始
└deltaobject当前帧的增量消息对象
└rolestring固定为 assistant,通常仅在首条内容帧下发
└contentstring文本正文增量片段,客户端按 choices[].index 顺序拼接即可得到完整回复
└tool_callsobject[]工具调用增量块;按 tool_calls[].index 聚合 id、function.name 与分段下发的 function.arguments 字符串
└finish_reasonstring | null生成过程中为 null;内容结束帧返回终止原因可选值stoplengthtool_callscontent_filter
usage(末帧)object请求传 stream_options: { "include_usage": true } 时,在 [DONE] 前额外推送一帧 choices: [] 并携带完整 usage
流式安全拦截帧finish_reason输出流中途触发内容安全策略时,服务端立即下发 {"choices":[{"index":0,"delta":{},"finish_reason":"content_filter"}]} 后紧跟 data: [DONE]\n\n 终止输出
流式异常帧object首包已发出后若链路中途异常,推送 {"error": {"message": "...", "code": "stream_error"}} 并紧跟 data: [DONE]\n\n

模型列表响应字段(GET /v1/models 与 GET /v1/models/{model})

字段类型说明
objectstringGET /v1/models 固定为 list(单模型接口直接返回下方 Model 对象)
dataobject[]GET /v1/models 返回当前密钥有权访问且已上架的全部模型数组(受密钥模型白名单限制)
└idstring模型唯一名称,即推理请求 model 参数取值(如 tengri-2)
└objectstring固定为 model
└createdinteger模型上架 Unix 秒级时间戳
└owned_bystring模型提供方标识,固定为 heimori

模型查询端点均不计费且账户余额为 0 时仍可调用;需通过受信任机构准入或密钥白名单审批,并具备 chat 或 embedding 产品权限。模型不存在或未启用时返回 error: { type: "invalid_request_error", param: "model", code: "model_not_found" }。

鉴权与请求头

请求头必填说明
Authorization条件必填OpenAI 与 DashScope 协议标准鉴权头,格式为 Bearer sk-heimori-...(亦接受裸 API Key,拒绝 Basic 等其他方案)
api-key条件必填兼容型 API Key 鉴权头(未传 Authorization 时生效)
x-api-key条件必填Anthropic Messages 协议标准鉴权头
Content-Type必填全部 JSON 推理与统计接口固定为 application/json

通用响应头

响应头说明
X-Request-Id单次请求唯一追踪 UUID,在用量统计查询调用明细与账单核对时使用
Content-Type标识响应体类型;SSE 流式响应同时附带 Cache-Control: no-cache 与 X-Accel-Buffering: no常见值application/json; charset=utf-8text/event-stream
X-RateLimit-Remaining当前 API Key 当日剩余调用次数配额(非负整数)
X-RateLimit-Reset日调用配额重置时间(北京时间次日 00:00:00 的 Unix 秒级时间戳)
Retry-After返回 HTTP 429(触发限流或模型并发繁忙)时的建议退避等待秒数

典型用法示例

cURL:非流式对话补全(含完整 JSON 响应与 usage)

发送标准 OpenAI Chat Completions 请求,返回完整回复与 token 消耗明细。

Bash / cURL
curl -X POST "https://cloud.heimori.cn/v1/chat/completions" \
  -H "Authorization: Bearer sk-heimori-..." \
  -H "Content-Type: application/json" \
  -d '{
    "model": "tengri-2",
    "temperature": 0.7,
    "max_completion_tokens": 1024,
    "messages": [
      {"role": "system", "content": "你是精通蒙汉双语的专业助手。"},
      {"role": "user", "content": "用传统蒙古文写一句欢迎词,并附中文释义。"}
    ]
  }'

响应示例:

JSON
{
  "id": "chatcmpl-20261128001",
  "object": "chat.completion",
  "created": 1795852800,
  "model": "tengri-2",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "ᠲᠠ ᠪᠦᠬᠦᠨ ᠳᠦ ᠮᠡᠨᠳᠦ ᠬᠦᠷᠭᠡᠶ᠎ᠡ᠃\n中文释义:向各位致以诚挚的问候。"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 34,
    "completion_tokens": 42,
    "total_tokens": 76,
    "prompt_tokens_details": {
      "cached_tokens": 0
    }
  }
}

Python(OpenAI SDK):流式对话与实时打印(含 include_usage)

安装官方 SDK(pip install openai),开启 stream=True 与 stream_options={"include_usage": True} 实时输出增量正文并读取末尾 token 统计。

Python
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["XM_API_KEY"],
    base_url="https://cloud.heimori.cn/v1",
)

stream = client.chat.completions.create(
    model="tengri-2",
    messages=[
        {"role": "system", "content": "回答简洁准确。"},
        {"role": "user", "content": "简述那达慕大会的传统男儿三艺。"},
    ],
    temperature=0.5,
    stream=True,
    stream_options={"include_usage": True},
)

for chunk in stream:
    if chunk.choices:
        delta = chunk.choices[0].delta
        if delta.content:
            print(delta.content, end="", flush=True)
        if chunk.choices[0].finish_reason == "content_filter":
            print("\n[流式输出触发内容安全过滤终止]")
    if chunk.usage:
        print(
            f"\n[usage] prompt={chunk.usage.prompt_tokens}, "
            f"completion={chunk.usage.completion_tokens}, "
            f"total={chunk.usage.total_tokens}"
        )

响应示例:

Text
data: {"id":"chatcmpl-stream-01","object":"chat.completion.chunk","created":1795852801,"model":"tengri-2","choices":[{"index":0,"delta":{"role":"assistant","content":"那达慕大会的传统男儿三艺包括"},"finish_reason":null}]}

data: {"id":"chatcmpl-stream-01","object":"chat.completion.chunk","created":1795852801,"model":"tengri-2","choices":[{"index":0,"delta":{"content":"摔跤(搏克)、赛马和射箭。"},"finish_reason":"stop"}]}

data: {"id":"chatcmpl-stream-01","object":"chat.completion.chunk","created":1795852801,"model":"tengri-2","choices":[],"usage":{"prompt_tokens":24,"completion_tokens":22,"total_tokens":46}}

data: [DONE]

Node.js(OpenAI SDK):多轮对话与函数调用完整闭环

完整演示 tools 定义、tool_choice 触发工具调用、本地执行后以 role: "tool" 回填并生成最终回答。

JavaScript
import OpenAI from "openai";

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

const tools = [
  {
    type: "function",
    function: {
      name: "get_weather",
      description: "查询指定城市的实时天气信息",
      parameters: {
        type: "object",
        properties: {
          city: { type: "string", description: "城市名称,如呼和浩特" },
          unit: { type: "string", enum: ["celsius", "fahrenheit"] },
        },
        required: ["city"],
        additionalProperties: false,
      },
    },
  },
];

const messages = [
  { role: "system", content: "你是旅行助手,需要天气数据时调用工具查询。" },
  { role: "user", content: "呼和浩特今天天气怎么样?适合户外活动吗?" },
];

// 第 1 轮:模型决定调用 get_weather
const first = await client.chat.completions.create({
  model: "tengri-2",
  messages,
  tools,
  tool_choice: "auto",
  parallel_tool_calls: true,
});

const assistantMsg = first.choices[0].message;
messages.push(assistantMsg);

// 第 2 轮:本地执行工具并将结果按 tool_call_id 回填
if (assistantMsg.tool_calls?.length) {
  for (const call of assistantMsg.tool_calls) {
    const args = JSON.parse(call.function.arguments);
    const toolResult = {
      city: args.city,
      condition: "晴",
      temperature_c: 18,
      wind: "微风 2 级",
    };
    messages.push({
      role: "tool",
      tool_call_id: call.id,
      content: JSON.stringify(toolResult),
    });
  }

  const finalResp = await client.chat.completions.create({
    model: "tengri-2",
    messages,
    tools,
  });
  console.log(finalResp.choices[0].message.content);
}

响应示例:

JSON
{
  "id": "chatcmpl-tool-round1",
  "object": "chat.completion",
  "created": 1795852810,
  "model": "tengri-2",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": null,
        "tool_calls": [
          {
            "id": "call_9a7c2e1b4d8f",
            "type": "function",
            "function": {
              "name": "get_weather",
              "arguments": "{\"city\":\"呼和浩特\",\"unit\":\"celsius\"}"
            }
          }
        ]
      },
      "finish_reason": "tool_calls"
    }
  ],
  "usage": {
    "prompt_tokens": 96,
    "completion_tokens": 21,
    "total_tokens": 117
  }
}

cURL:结构化输出(response_format: json_schema)

使用 json_schema 约束模型严格按照指定字段类型输出 JSON,便于后端程序直接反序列化。

Bash / cURL
curl -X POST "https://cloud.heimori.cn/v1/chat/completions" \
  -H "Authorization: Bearer sk-heimori-..." \
  -H "Content-Type: application/json" \
  -d '{
    "model": "tengri-2-pro",
    "temperature": 0,
    "messages": [
      {"role": "user", "content": "从文本中提取活动信息:2026年7月15日,呼和浩特市举办第36届草原那达慕大会,预计吸引游客5万人。"}
    ],
    "response_format": {
      "type": "json_schema",
      "json_schema": {
        "name": "event_extraction",
        "strict": true,
        "schema": {
          "type": "object",
          "properties": {
            "event_name": {"type": "string"},
            "city": {"type": "string"},
            "date": {"type": "string"},
            "expected_visitors": {"type": "integer"}
          },
          "required": ["event_name", "city", "date", "expected_visitors"],
          "additionalProperties": false
        }
      }
    }
  }'

响应示例:

JSON
{
  "id": "chatcmpl-schema-20261128",
  "object": "chat.completion",
  "created": 1795852820,
  "model": "tengri-2-pro",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "{\"event_name\":\"第36届草原那达慕大会\",\"city\":\"呼和浩特市\",\"date\":\"2026-07-15\",\"expected_visitors\":50000}"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 82,
    "completion_tokens": 35,
    "total_tokens": 117
  }
}

Python(OpenAI SDK):多模态输入(图片 URL / Base64 与 PDF 文档问答)

在 messages[].content 中混合传递 text、image_url(URL 或 Base64 Data URI)与 file(PDF Base64)内容块。

Python
import base64
import os
from pathlib import Path
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["XM_API_KEY"],
    base_url="https://cloud.heimori.cn/v1",
)

# 1. 图片理解(支持公网 HTTPS URL 或本地 Base64 Data URI)
img_b64 = base64.b64encode(Path("mongolian-sign.jpg").read_bytes()).decode("ascii")
vision_resp = client.chat.completions.create(
    model="tengri-2-max",
    messages=[
        {
            "role": "user",
            "content": [
                {"type": "text", "text": "识别图中的传统蒙古文文字并翻译成中文。"},
                {
                    "type": "image_url",
                    "image_url": {
                        "url": f"data:image/jpeg;base64,{img_b64}",
                        "detail": "high",
                    },
                },
            ],
        }
    ],
)
print("图片理解:", vision_resp.choices[0].message.content)

# 2. PDF 文档问答(file 内容块)
pdf_b64 = base64.b64encode(Path("annual-report.pdf").read_bytes()).decode("ascii")
doc_resp = client.chat.completions.create(
    model="tengri-2-max",
    messages=[
        {
            "role": "user",
            "content": [
                {"type": "text", "text": "概括这份 PDF 的三项核心结论。"},
                {
                    "type": "file",
                    "file": {
                        "filename": "annual-report.pdf",
                        "file_data": f"data:application/pdf;base64,{pdf_b64}",
                    },
                },
            ],
        }
    ],
)
print("文档问答:", doc_resp.choices[0].message.content)

响应示例:

JSON
{
  "id": "chatcmpl-mm-20261128",
  "object": "chat.completion",
  "created": 1795852835,
  "model": "tengri-2-max",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "图中传统蒙古文为「ᠮᠣᠩᠭᠣᠯ ᠬᠡᠯᠡ」,中文释义为「蒙古语」。"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 412,
    "completion_tokens": 31,
    "total_tokens": 443
  }
}

计费口径、内容安全与接入配置

项目规格与说明
Token 计费与推理口径按本次请求实际消耗的输入与输出 token 实时扣减账户余额;深度推理模型仅输出最终正文内容,内部推理过程消耗的 token 计入 usage.completion_tokens 并按输出单价结算;命中提示词缓存时通过 usage.prompt_tokens_details.cached_tokens 返回缓存 token 数
账户余额门槛与计费模式Tengri 大模型与向量嵌入按模型目录配置的计费方式实时结算(按输入/输出 token 计费或按单次调用固定价计费,叠加密钥分组倍率),发起调用前账户余额必须严格 > 0(余额 ≤ 0 或欠费停服返回 403 insufficient_user_quota);模型列表查询、Token 估算与账单查询接口不计费且在余额为 0 时可用
流式中断计费按 token 计费的模型在流式输出期间若客户端主动断开连接(日志记录 HTTP 499)或在已输出部分内容后因链路异常中断(502 stream_error),按已实际生成的 token 结算费用;尚未输出任何首字即失败的请求不计费
默认限流配额单 API Key 默认限流池为 100 QPS、60 并发、1,000,000 次/日;触达平台密钥限流时返回 429 并附带 Retry-After、X-RateLimit-Remaining、X-RateLimit-Reset 响应头;模型服务繁忙限流同样返回 429(服务端提供重试间隔时透传 Retry-After)限流错误码rate_limitedconcurrency_limiteddaily_quota_exceeded
请求体体积与连接超时单次 JSON 请求体上限 200 MB(超出返回 HTTP 413);非流式与流式长连接空闲超时均为 50 分钟(每次收到有效网络数据包自动重置计时)
内容安全审核所有文本与多模态请求的输入及输出均实时接入内容安全审核:输入触发策略时按协议返回 400(OpenAI / Responses 协议返回 content_policy_violation 及 moderation 详情对象,Anthropic 协议返回 invalid_request_error,均不计费);非流式输出触发拦截时返回 HTTP 200(正文置空,OpenAI 标记 finish_reason: "content_filter"、Responses 标记 status: "incomplete");流式输出触发拦截时立即推送终止帧,详见风控、内容安全与合规指南
多协议错误体与排障错误体格式与调用协议一一对应(OpenAI / Anthropic),详见错误码;定位单次调用日志或核对账单时,请在用量统计中输入响应头 X-Request-Id 查询

支持语种

  • 没有语种参数:模型直接理解与生成多语文本,对传统蒙古文、西里尔蒙古文、藏文、维吾尔文等民族语种做过专项优化。
  • 需要固定输出语种时在提示词中说明即可。

完整代码表与各产品对照见「语种与语言代码」。

计费

  • 按模型目录配置的计费方式从账户余额实时结算(按输入/输出 token 单价或按单次固定价格,叠加密钥分组倍率),各模型当前计价见本页下方「当前价格」或定价页。
  • 按 token 计费模型的用量 = 输入 token + 输出 token,响应 usage 字段返回本次消耗明细(含图片、音频、视频等输入折算);按次计费模型按成功调用次数结算。
  • 仅对成功调用计费(流式输出期间客户端主动中断 HTTP 499 或已吐字后中断按已生成 token 结算;首字前失败不扣费)。

当前价格

模型说明
输入
元 / 百万 token
输出
元 / 百万 token
tengri-2-max
旗舰档,面向长文本、复杂推理与高要求专业任务¥20¥80
tengri-2推荐
标准档,兼顾传统与西里尔蒙古文、藏文、维吾尔文及中英文通用能力与性价比¥4¥20
tengri-2-fast
快速档,首字响应更快、吞吐更高,适合实时交互与高并发批量场景¥8¥40
tengri-2-pro
专业档,适合长文本处理、深度分析与复杂推理任务¥12¥36
tengri-t1
T1 标准档,响应快、性价比高¥4¥16
tengri-t1-pro
T1 专业档¥8¥24

API 参考

本产品共 22 个接口,全部接口见API 参考索引。

创建对话补全(OpenAI 兼容)

POST/v1/chat/completions

Tengri 大模型对话补全接口,兼容 OpenAI chat/completions 协议。

基址与鉴权:统一使用 https://cloud.heimori.cn/v1, 请求头携带 Authorization: Bearer <API Key>(亦支持 api-key 或 x-api-key 请求头)。

可选模型(单价见官网「Tengri AI 模型价格」):tengri-2-max / tengri-2 / tengri-2-fast / tengri-2-pro / tengri-t1 / tengri-t1-pro

支持文本与图片、音频、视频、文件多模态输入,Function Calling 工具调用,结构化 JSON 输出,以及 stream: true SSE 流式增量返回。

请求参数application/json

参数类型说明
model必填
string
模型名,当前可选:tengri-2-max / tengri-2 / tengri-2-fast / tengri-2-pro / tengri-t1 / tengri-t1-pro
可选值:tengri-2-maxtengri-2tengri-2-fasttengri-2-protengri-t1tengri-t1-pro
示例:tengri-2-max
messages必填
array<object>
对话消息列表(多轮对话由调用方携带历史)
示例:[{"role":"system","content":"You are a helpful assistant."},{"role":"user","content":"介绍一下传统蒙古文的书写方向。"}]
└role必填
string
消息角色
可选值:systemdeveloperuserassistanttool
└content可选
string | null
字符串,或分段数组:text / image_url / input_audio / input_video / file;assistant 仅发工具调用时可为 null
└name可选
string
可选发送者名称
└tool_calls可选
array<object>
role=assistant 回传历史工具调用时携带
└tool_call_id可选
string
role=tool 时必填,对应模型返回的工具调用 ID
stream可选
boolean
true 时以 SSE 流式返回增量内容,末尾输出 data: [DONE]
默认值:false
stream_options可选
object
流式附加选项(仅 stream=true 时生效)
└include_usage可选
boolean
最后一条数据帧返回 token 用量明细
默认值:false
max_completion_tokens可选
integer
最大输出 token 数(含深度推理消耗)
max_tokens可选
integer
最大输出 token 数
temperature可选
number
采样温度
top_p可选
number
核采样概率阈值
n可选
integer
候选回复条数
默认值:1
stop可选
string
停止词字符串或数组
presence_penalty可选
number
话题存在惩罚
默认值:0
frequency_penalty可选
number
词频重复惩罚
默认值:0
logit_bias可选
object
采样偏置
seed可选
integer
随机种子
tools可选
array<object>
函数工具定义列表
└type必填
string
可选值:function
└function必填
object
└name必填
string
└description可选
string
└parameters可选
object
JSON Schema 参数定义
└strict可选
boolean
tool_choice可选
string
工具调用策略:auto / none / required,或指定函数对象
可选值:autononerequired
parallel_tool_calls可选
boolean
是否允许单轮并行发起多个工具调用
默认值:true
response_format可选
object
输出格式控制(text / json_object / json_schema)
user可选
string
调用方终端用户标识
metadata可选
object
自定义键值元数据

响应

HTTP 200application/jsonOpenAI 兼容的 chat.completion 对象
响应头
响应头类型说明
X-Request-Id
string
本次请求唯一追踪 ID,排查问题与账单核对时提供
示例:a3f5c8e2-91b4-4d7a-8e62-1f90c3b8e412
X-RateLimit-Remaining
integer
当日剩余调用次数配额
示例:999850
X-RateLimit-Reset
integer
日配额重置 Unix 秒级时间戳(北京时间次日 0 点)
示例:1795881600
响应字段
字段类型说明
id
string
本次补全唯一响应 ID
object
string
固定为 chat.completion
可选值:chat.completion
created
integer
Unix 秒级时间戳
model
string
本次调用的模型名
system_fingerprint
string
可选服务端配置指纹
choices
array<object>
└index
integer
└message
object
└role
string
可选值:assistant
└content
string | null
回复文本内容
└tool_calls
array<object>
函数工具调用列表
└finish_reason
string
生成终止原因
可选值:stoplengthtool_callscontent_filter
usage
object
└prompt_tokens
integer
输入 token 数
└completion_tokens
integer
输出 token 数(含深度推理消耗)
└total_tokens
integer
总 token 数
└prompt_tokens_details
object
└cached_tokens
integer
命中缓存的输入 token 数
响应示例
200 响应
{
  "id": "chatcmpl-20261128001",
  "object": "chat.completion",
  "created": 1795852800,
  "model": "tengri-2-max",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "传统蒙古文自上而下书写、列从左向右排列,是仍在广泛使用的竖排文字之一。"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 29,
    "completion_tokens": 64,
    "total_tokens": 93,
    "prompt_tokens_details": {
      "cached_tokens": 0
    }
  }
}
另支持非 JSON 响应格式:text/event-stream

代码示例

curl -N -X POST "https://cloud.heimori.cn/v1/chat/completions" \
  -H "Authorization: Bearer sk-heimori-..." \
  -H "Accept: text/event-stream" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "tengri-2-max",
  "messages": [
    {
      "role": "system",
      "content": "You are a helpful assistant."
    },
    {
      "role": "user",
      "content": "介绍一下传统蒙古文的书写方向。"
    }
  ]
}'

创建模型响应(OpenAI Responses 兼容)

POST/v1/responses

兼容 OpenAI Responses API(POST /v1/responses),可直接配合新版 OpenAI SDK client.responses.create() 调用。

基址与鉴权:统一使用 https://cloud.heimori.cn/v1, 请求头携带 Authorization: Bearer <API Key>(亦支持 api-key 或 x-api-key 请求头)。

可选模型(单价见官网「Tengri AI 模型价格」):tengri-2-max / tengri-2 / tengri-2-fast / tengri-2-pro / tengri-t1 / tengri-t1-pro

请求参数application/json

参数类型说明
model必填
string
模型名,当前可选:tengri-2-max / tengri-2 / tengri-2-fast / tengri-2-pro / tengri-t1 / tengri-t1-pro
可选值:tengri-2-maxtengri-2tengri-2-fasttengri-2-protengri-t1tengri-t1-pro
示例:tengri-2-max
input必填
string
输入文本字符串或 Responses 条目数组
instructions可选
string
系统指令(可选)
stream可选
boolean
true 时以 SSE 流式返回事件流
默认值:false
max_output_tokens可选
integer
限制最大输出 token 数
temperature可选
number
采样温度
top_p可选
number
核采样概率阈值
tools可选
array<object>
函数工具定义列表
tool_choice可选
string
工具调用策略
可选值:autononerequired
parallel_tool_calls可选
boolean
默认值:true
text可选
object
结构化输出格式配置(text.format)
user可选
string
调用方终端用户标识
metadata可选
object

响应

HTTP 200application/jsonOpenAI Responses 格式对象
响应头
响应头类型说明
X-Request-Id
string
本次请求唯一追踪 ID,排查问题与账单核对时提供
示例:a3f5c8e2-91b4-4d7a-8e62-1f90c3b8e412
X-RateLimit-Remaining
integer
当日剩余调用次数配额
示例:999850
X-RateLimit-Reset
integer
日配额重置 Unix 秒级时间戳(北京时间次日 0 点)
示例:1795881600
响应字段
字段类型说明
id
string
object
string
可选值:response
created_at
integer
status
string
可选值:completedincompletefailed
model
string
output
array<object>
usage
object
└input_tokens
integer
└output_tokens
integer
└total_tokens
integer
响应示例
200 响应
{
  "id": "resp_20261128001",
  "object": "response",
  "created_at": 1795852900,
  "status": "completed",
  "model": "tengri-2-max",
  "output": [
    {
      "id": "msg_20261128001",
      "type": "message",
      "status": "completed",
      "role": "assistant",
      "content": [
        {
          "type": "output_text",
          "text": "ᠲᠠ ᠪᠦᠬᠦᠨ ᠳᠦ ᠮᠡᠨᠳᠦ ᠬᠦᠷᠭᠡᠶ᠎ᠡ᠃",
          "annotations": []
        }
      ]
    }
  ],
  "usage": {
    "input_tokens": 14,
    "output_tokens": 18,
    "total_tokens": 32
  }
}
另支持非 JSON 响应格式:text/event-stream

代码示例

curl -N -X POST "https://cloud.heimori.cn/v1/responses" \
  -H "Authorization: Bearer sk-heimori-..." \
  -H "Accept: text/event-stream" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "tengri-2-max",
  "input": "用传统蒙古文写一句欢迎词"
}'

估算 Responses 输入 Token 数

POST/v1/responses/input_tokens

估算 POST /v1/responses 输入文本与系统指令的 token 数;本接口不计费且在余额为 0 时可用。

请求参数application/json

参数类型说明
model必填
string
模型名,当前可选:tengri-2-max / tengri-2 / tengri-2-fast / tengri-2-pro / tengri-t1 / tengri-t1-pro
可选值:tengri-2-maxtengri-2tengri-2-fasttengri-2-protengri-t1tengri-t1-pro
示例:tengri-2-max
input必填
string
输入文本字符串或 Responses 消息数组
instructions可选
string
可选系统指令

响应

HTTP 200application/json估算的输入 token 数量
响应头
响应头类型说明
X-Request-Id
string
本次请求唯一追踪 ID,排查问题与账单核对时提供
示例:a3f5c8e2-91b4-4d7a-8e62-1f90c3b8e412
X-RateLimit-Remaining
integer
当日剩余调用次数配额
示例:999850
X-RateLimit-Reset
integer
日配额重置 Unix 秒级时间戳(北京时间次日 0 点)
示例:1795881600
响应字段
字段类型说明
object
string
可选值:response.input_tokens
input_tokens
integer
响应示例
200 响应
{
  "object": "response.input_tokens",
  "input_tokens": 18
}

代码示例

curl -X POST "https://cloud.heimori.cn/v1/responses/input_tokens" \
  -H "Authorization: Bearer sk-heimori-..." \
  -H "Content-Type: application/json" \
  -d '{
  "model": "tengri-2-max",
  "input": "介绍一下传统蒙古文的历史演变"
}'

创建对话消息(Anthropic Messages 兼容)

POST/v1/messages

兼容 Anthropic Messages API(POST /v1/messages),base_url 填 https://cloud.heimori.cn,支持 x-api-key 或 Authorization: Bearer。

可选模型(单价见官网「Tengri AI 模型价格」):tengri-2-max / tengri-2 / tengri-2-fast / tengri-2-pro / tengri-t1 / tengri-t1-pro

请求参数application/json

参数类型说明
anthropic-versionheader可选
string
Anthropic 协议版本头,推荐传 `2023-06-01`
示例:2023-06-01
model必填
string
模型名,当前可选:tengri-2-max / tengri-2 / tengri-2-fast / tengri-2-pro / tengri-t1 / tengri-t1-pro
可选值:tengri-2-maxtengri-2tengri-2-fasttengri-2-protengri-t1tengri-t1-pro
示例:tengri-2-max
max_tokens必填
integer
本次回复的最大输出 token 数
示例:1024
system可选
string
系统提示词
messages必填
array<object>
Anthropic 格式消息列表(role 仅支持 user / assistant)
示例:[{"role":"user","content":"介绍一下传统蒙古文的书写方向。"}]
stream可选
boolean
true 时以 Anthropic SSE 生命周期事件流返回
默认值:false
temperature可选
number
采样温度
top_p可选
number
核采样累计概率阈值
stop_sequences可选
array<string>
自定义停止词序列
tools可选
array<object>
Anthropic 格式工具定义列表
tool_choice可选
object
工具选择策略

响应

HTTP 200application/jsonAnthropic Messages 格式响应对象
响应头
响应头类型说明
X-Request-Id
string
本次请求唯一追踪 ID,排查问题与账单核对时提供
示例:a3f5c8e2-91b4-4d7a-8e62-1f90c3b8e412
X-RateLimit-Remaining
integer
当日剩余调用次数配额
示例:999850
X-RateLimit-Reset
integer
日配额重置 Unix 秒级时间戳(北京时间次日 0 点)
示例:1795881600
响应字段
字段类型说明
id
string
type
string
可选值:message
role
string
可选值:assistant
model
string
content
array<object>
stop_reason
string | null
可选值:end_turnmax_tokenstool_use
stop_sequence
string | null
usage
object
└input_tokens
integer
└output_tokens
integer
└cache_read_input_tokens
integer
响应示例
200 响应
{
  "id": "msg_20261128001",
  "type": "message",
  "role": "assistant",
  "model": "tengri-2-max",
  "content": [
    {
      "type": "text",
      "text": "传统蒙古文自上而下书写、列从左向右排列。"
    }
  ],
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "usage": {
    "input_tokens": 24,
    "output_tokens": 28
  }
}
另支持非 JSON 响应格式:text/event-stream

代码示例

curl -N -X POST "https://cloud.heimori.cn/v1/messages" \
  -H "Authorization: Bearer sk-heimori-..." \
  -H "Accept: text/event-stream" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "tengri-2-max",
  "max_tokens": 1024,
  "messages": [
    {
      "role": "user",
      "content": "介绍一下传统蒙古文的书写方向。"
    }
  ]
}'

统计消息输入 Token 数(Anthropic 兼容)

POST/v1/messages/count_tokens

兼容 Anthropic POST /v1/messages/count_tokens,计算消息数组、系统提示词与工具定义的输入 token 数。本接口不计费。

请求参数application/json

参数类型说明
anthropic-versionheader可选
string
Anthropic 协议版本头,推荐传 `2023-06-01`
示例:2023-06-01
model必填
string
模型名,当前可选:tengri-2-max / tengri-2 / tengri-2-fast / tengri-2-pro / tengri-t1 / tengri-t1-pro
可选值:tengri-2-maxtengri-2tengri-2-fasttengri-2-protengri-t1tengri-t1-pro
示例:tengri-2-max
system可选
string
messages必填
array<object>
示例:[{"role":"user","content":"介绍一下传统蒙古文的书写方向。"}]
tools可选
array<object>

响应

HTTP 200application/json输入 token 统计结果
响应头
响应头类型说明
X-Request-Id
string
本次请求唯一追踪 ID,排查问题与账单核对时提供
示例:a3f5c8e2-91b4-4d7a-8e62-1f90c3b8e412
X-RateLimit-Remaining
integer
当日剩余调用次数配额
示例:999850
X-RateLimit-Reset
integer
日配额重置 Unix 秒级时间戳(北京时间次日 0 点)
示例:1795881600
响应字段
字段类型说明
input_tokens
integer
响应示例
200 响应
{
  "input_tokens": 26
}

代码示例

curl -X POST "https://cloud.heimori.cn/v1/messages/count_tokens" \
  -H "Authorization: Bearer sk-heimori-..." \
  -H "Content-Type: application/json" \
  -d '{
  "model": "tengri-2-max",
  "messages": [
    {
      "role": "user",
      "content": "介绍一下传统蒙古文的书写方向。"
    }
  ]
}'

创建文本续写(Legacy Completions 兼容)

POST/v1/completions

兼容 OpenAI Legacy POST /v1/completions 文本续写协议。

基址与鉴权:统一使用 https://cloud.heimori.cn/v1, 请求头携带 Authorization: Bearer <API Key>(亦支持 api-key 或 x-api-key 请求头)。

可选模型(单价见官网「Tengri AI 模型价格」):tengri-2-max / tengri-2 / tengri-2-fast / tengri-2-pro / tengri-t1 / tengri-t1-pro

请求参数application/json

参数类型说明
model必填
string
模型名,当前可选:tengri-2-max / tengri-2 / tengri-2-fast / tengri-2-pro / tengri-t1 / tengri-t1-pro
可选值:tengri-2-maxtengri-2tengri-2-fasttengri-2-protengri-t1tengri-t1-pro
示例:tengri-2-max
prompt必填
string
续写提示文本
max_tokens可选
integer
最大输出 token 数
示例:256
temperature可选
number
采样温度
top_p可选
number
核采样概率阈值
n可选
integer
候选续写条数
默认值:1
stream可选
boolean
是否以 SSE 流式返回
默认值:false
stop可选
string
停止词
echo可选
boolean
是否回显 prompt
默认值:false
suffix可选
string
续写后追加后缀
presence_penalty可选
number
frequency_penalty可选
number
seed可选
integer
user可选
string

响应

HTTP 200application/jsonOpenAI 兼容的 text_completion 对象
响应头
响应头类型说明
X-Request-Id
string
本次请求唯一追踪 ID,排查问题与账单核对时提供
示例:a3f5c8e2-91b4-4d7a-8e62-1f90c3b8e412
X-RateLimit-Remaining
integer
当日剩余调用次数配额
示例:999850
X-RateLimit-Reset
integer
日配额重置 Unix 秒级时间戳(北京时间次日 0 点)
示例:1795881600
响应字段
字段类型说明
id
string
object
string
可选值:text_completion
created
integer
model
string
choices
array<object>
└text
string
└index
integer
└logprobs
object | null
└finish_reason
string
可选值:stoplengthcontent_filter
usage
object
└prompt_tokens
integer
└completion_tokens
integer
└total_tokens
integer
响应示例
200 响应
{
  "id": "cmpl-20261128001",
  "object": "text_completion",
  "created": 1795853000,
  "model": "tengri-2-max",
  "choices": [
    {
      "text": "自上而下竖排书写,行序从左向右排列。",
      "index": 0,
      "logprobs": null,
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 12,
    "completion_tokens": 20,
    "total_tokens": 32
  }
}
另支持非 JSON 响应格式:text/event-stream

代码示例

curl -N -X POST "https://cloud.heimori.cn/v1/completions" \
  -H "Authorization: Bearer sk-heimori-..." \
  -H "Accept: text/event-stream" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "tengri-2-max",
  "prompt": "传统蒙古文的书写特点是:"
}'

查询可用模型列表(OpenAI 兼容)

GET/v1/models

列出当前密钥有权访问且已上架的模型清单;本接口不计费。

基址与鉴权:统一使用 https://cloud.heimori.cn/v1, 请求头携带 Authorization: Bearer <API Key>(亦支持 api-key 或 x-api-key 请求头)。

请求参数

无请求参数

响应

HTTP 200application/json当前公开可用的模型列表
响应头
响应头类型说明
X-Request-Id
string
本次请求唯一追踪 ID,排查问题与账单核对时提供
示例:a3f5c8e2-91b4-4d7a-8e62-1f90c3b8e412
X-RateLimit-Remaining
integer
当日剩余调用次数配额
示例:999850
X-RateLimit-Reset
integer
日配额重置 Unix 秒级时间戳(北京时间次日 0 点)
示例:1795881600
响应字段
字段类型说明
object
string
可选值:list
data
array<object>
└id
string
模型名称
└object
string
可选值:model
└created
integer
上架 Unix 秒级时间戳
└owned_by
string
示例:heimori
响应示例
200 响应
{
  "object": "list",
  "data": [
    {
      "id": "tengri-2-max",
      "object": "model",
      "created": 1700000000,
      "owned_by": "heimori"
    }
  ]
}

代码示例

curl -X GET "https://cloud.heimori.cn/v1/models" \
  -H "Authorization: Bearer sk-heimori-..."

查询单个模型信息(OpenAI 兼容)

GET/v1/models/{model}

按模型名查询单个模型的可用状态与基础元数据;若不存在返回 404 model_not_found。

请求参数

参数类型说明
modelpath必填
string
模型名称
示例:tengri-2-max

响应

HTTP 200application/json模型对象
响应头
响应头类型说明
X-Request-Id
string
本次请求唯一追踪 ID,排查问题与账单核对时提供
示例:a3f5c8e2-91b4-4d7a-8e62-1f90c3b8e412
X-RateLimit-Remaining
integer
当日剩余调用次数配额
示例:999850
X-RateLimit-Reset
integer
日配额重置 Unix 秒级时间戳(北京时间次日 0 点)
示例:1795881600
响应字段
字段类型说明
id
string
模型名称
object
string
可选值:model
created
integer
上架 Unix 秒级时间戳
owned_by
string
示例:heimori
响应示例
200 响应
{
  "id": "tengri-2-max",
  "object": "model",
  "created": 1700000000,
  "owned_by": "heimori"
}

代码示例

curl -X GET "https://cloud.heimori.cn/v1/models/tengri-2-max" \
  -H "Authorization: Bearer sk-heimori-..."

查询账户余额与额度上限(OpenAI Billing 兼容)

GET/v1/dashboard/billing/subscription

返回当前 API Key 所属云账户的可用余额与总额度上限(同时挂载于 /dashboard/billing/subscription)。本接口不计费。

请求参数

无请求参数

响应

HTTP 200application/json账户额度与人民币余额快照
响应头
响应头类型说明
X-Request-Id
string
本次请求唯一追踪 ID,排查问题与账单核对时提供
示例:a3f5c8e2-91b4-4d7a-8e62-1f90c3b8e412
X-RateLimit-Remaining
integer
当日剩余调用次数配额
示例:999850
X-RateLimit-Reset
integer
日配额重置 Unix 秒级时间戳(北京时间次日 0 点)
示例:1795881600
响应字段
字段类型说明
object
string
可选值:billing_subscription
has_payment_method
boolean
示例:true
soft_limit_usd
number
兼容额度数值(单位为元,保留协议字段名)
hard_limit_usd
number
兼容额度硬上限(同 soft_limit_usd)
system_hard_limit_usd
number
系统兼容额度硬上限(同 soft_limit_usd)
access_until
integer
当前密钥到期 Unix 秒级时间戳,0 表示无期限
balance_yuan
number
人民币可用额度(元)
响应示例
200 响应
{
  "object": "billing_subscription",
  "has_payment_method": true,
  "soft_limit_usd": 1500,
  "hard_limit_usd": 1500,
  "system_hard_limit_usd": 1500,
  "access_until": 0,
  "balance_yuan": 1280.5
}

代码示例

curl -X GET "https://cloud.heimori.cn/v1/dashboard/billing/subscription" \
  -H "Authorization: Bearer sk-heimori-..."

查询当前密钥区间消费金额(OpenAI Billing 兼容)

GET/v1/dashboard/billing/usage

按可选 UTC 日期 start_date / end_date(YYYY-MM-DD)查询当前 API Key 在指定范围内的累计消费金额(同时挂载于 /dashboard/billing/usage)。本接口不计费。

请求参数

参数类型说明
start_datequery可选
string
UTC 起始日期(YYYY-MM-DD)
示例:2026-11-01
end_datequery可选
string
UTC 结束日期(YYYY-MM-DD)
示例:2026-11-30

响应

HTTP 200application/json当前 API Key 消费汇总
响应头
响应头类型说明
X-Request-Id
string
本次请求唯一追踪 ID,排查问题与账单核对时提供
示例:a3f5c8e2-91b4-4d7a-8e62-1f90c3b8e412
X-RateLimit-Remaining
integer
当日剩余调用次数配额
示例:999850
X-RateLimit-Reset
integer
日配额重置 Unix 秒级时间戳(北京时间次日 0 点)
示例:1795881600
响应字段
字段类型说明
object
string
可选值:list
total_usage
number
累计消费(分)
total_amount_yuan
number
累计消费(元)
响应示例
200 响应
{
  "object": "list",
  "total_usage": 21950,
  "total_amount_yuan": 219.5
}

代码示例

curl -X GET "https://cloud.heimori.cn/v1/dashboard/billing/usage" \
  -H "Authorization: Bearer sk-heimori-..."

查询可用额度与赠金(OpenAI Billing 兼容)

GET/v1/dashboard/billing/credit_grants

返回与 /v1/dashboard/billing/subscription 一致的账户额度与余额信息(同时挂载于 /dashboard/billing/credit_grants)。本接口不计费。

请求参数

无请求参数

响应

HTTP 200application/json账户额度与人民币余额快照
响应头
响应头类型说明
X-Request-Id
string
本次请求唯一追踪 ID,排查问题与账单核对时提供
示例:a3f5c8e2-91b4-4d7a-8e62-1f90c3b8e412
X-RateLimit-Remaining
integer
当日剩余调用次数配额
示例:999850
X-RateLimit-Reset
integer
日配额重置 Unix 秒级时间戳(北京时间次日 0 点)
示例:1795881600
响应字段
字段类型说明
object
string
可选值:billing_subscription
has_payment_method
boolean
示例:true
soft_limit_usd
number
兼容额度数值(单位为元,保留协议字段名)
hard_limit_usd
number
兼容额度硬上限(同 soft_limit_usd)
system_hard_limit_usd
number
系统兼容额度硬上限(同 soft_limit_usd)
access_until
integer
当前密钥到期 Unix 秒级时间戳,0 表示无期限
balance_yuan
number
人民币可用额度(元)
响应示例
200 响应
{
  "object": "billing_subscription",
  "has_payment_method": true,
  "soft_limit_usd": 1500,
  "hard_limit_usd": 1500,
  "system_hard_limit_usd": 1500,
  "access_until": 0,
  "balance_yuan": 1280.5
}

代码示例

curl -X GET "https://cloud.heimori.cn/v1/dashboard/billing/credit_grants" \
  -H "Authorization: Bearer sk-heimori-..."

DashScope 兼容基址对话补全

POST/compatible-mode/v1/chat/completions

提供与 DashScope 相同路径前缀 /compatible-mode/v1 的兼容入口,参数与计费与 POST /v1/chat/completions 一致。

请求参数application/json

参数类型说明
model必填
string
模型名,当前可选:tengri-2-max / tengri-2 / tengri-2-fast / tengri-2-pro / tengri-t1 / tengri-t1-pro
可选值:tengri-2-maxtengri-2tengri-2-fasttengri-2-protengri-t1tengri-t1-pro
示例:tengri-2-max
messages必填
array<object>
对话消息列表(多轮对话由调用方携带历史)
示例:[{"role":"system","content":"You are a helpful assistant."},{"role":"user","content":"介绍一下传统蒙古文的书写方向。"}]
└role必填
string
消息角色
可选值:systemdeveloperuserassistanttool
└content可选
string | null
字符串,或分段数组:text / image_url / input_audio / input_video / file;assistant 仅发工具调用时可为 null
└name可选
string
可选发送者名称
└tool_calls可选
array<object>
role=assistant 回传历史工具调用时携带
└tool_call_id可选
string
role=tool 时必填,对应模型返回的工具调用 ID
stream可选
boolean
true 时以 SSE 流式返回增量内容,末尾输出 data: [DONE]
默认值:false
stream_options可选
object
流式附加选项(仅 stream=true 时生效)
└include_usage可选
boolean
最后一条数据帧返回 token 用量明细
默认值:false
max_completion_tokens可选
integer
最大输出 token 数(含深度推理消耗)
max_tokens可选
integer
最大输出 token 数
temperature可选
number
采样温度
top_p可选
number
核采样概率阈值
n可选
integer
候选回复条数
默认值:1
stop可选
string
停止词字符串或数组
presence_penalty可选
number
话题存在惩罚
默认值:0
frequency_penalty可选
number
词频重复惩罚
默认值:0
logit_bias可选
object
采样偏置
seed可选
integer
随机种子
tools可选
array<object>
函数工具定义列表
└type必填
string
可选值:function
└function必填
object
└name必填
string
└description可选
string
└parameters可选
object
JSON Schema 参数定义
└strict可选
boolean
tool_choice可选
string
工具调用策略:auto / none / required,或指定函数对象
可选值:autononerequired
parallel_tool_calls可选
boolean
是否允许单轮并行发起多个工具调用
默认值:true
response_format可选
object
输出格式控制(text / json_object / json_schema)
└type可选
string
可选值:textjson_objectjson_schema
└json_schema可选
object
user可选
string
调用方终端用户标识
metadata可选
object
自定义键值元数据

响应

HTTP 200application/jsonOpenAI 兼容的 chat.completion 对象
响应头
响应头类型说明
X-Request-Id
string
本次请求唯一追踪 ID,排查问题与账单核对时提供
示例:a3f5c8e2-91b4-4d7a-8e62-1f90c3b8e412
X-RateLimit-Remaining
integer
当日剩余调用次数配额
示例:999850
X-RateLimit-Reset
integer
日配额重置 Unix 秒级时间戳(北京时间次日 0 点)
示例:1795881600
响应字段
字段类型说明
id
string
本次补全唯一响应 ID
object
string
固定为 chat.completion
可选值:chat.completion
created
integer
Unix 秒级时间戳
model
string
本次调用的模型名
system_fingerprint
string
可选服务端配置指纹
choices
array<object>
└index
integer
└message
object
└role
string
可选值:assistant
└content
string | null
回复文本内容
└tool_calls
array<object>
函数工具调用列表
└finish_reason
string
生成终止原因
可选值:stoplengthtool_callscontent_filter
usage
object
└prompt_tokens
integer
输入 token 数
└completion_tokens
integer
输出 token 数(含深度推理消耗)
└total_tokens
integer
总 token 数
└prompt_tokens_details
object
└cached_tokens
integer
命中缓存的输入 token 数
响应示例
200 响应
{
  "id": "chatcmpl-20261128001",
  "object": "chat.completion",
  "created": 1795852800,
  "model": "tengri-2-max",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "传统蒙古文自上而下书写、列从左向右排列,是仍在广泛使用的竖排文字之一。"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 29,
    "completion_tokens": 64,
    "total_tokens": 93,
    "prompt_tokens_details": {
      "cached_tokens": 0
    }
  }
}
另支持非 JSON 响应格式:text/event-stream

代码示例

curl -N -X POST "https://cloud.heimori.cn/compatible-mode/v1/chat/completions" \
  -H "Authorization: Bearer sk-heimori-..." \
  -H "Accept: text/event-stream" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "tengri-2-max",
  "messages": [
    {
      "role": "system",
      "content": "You are a helpful assistant."
    },
    {
      "role": "user",
      "content": "介绍一下传统蒙古文的书写方向。"
    }
  ]
}'

DashScope 兼容基址模型列表查询

GET/compatible-mode/v1/models

列出当前密钥有权访问且已上架的模型清单;本接口不计费。

基址与鉴权:统一使用 https://cloud.heimori.cn/v1, 请求头携带 Authorization: Bearer <API Key>(亦支持 api-key 或 x-api-key 请求头)。

请求参数

无请求参数

响应

HTTP 200application/json当前公开可用的模型列表
响应头
响应头类型说明
X-Request-Id
string
本次请求唯一追踪 ID,排查问题与账单核对时提供
示例:a3f5c8e2-91b4-4d7a-8e62-1f90c3b8e412
X-RateLimit-Remaining
integer
当日剩余调用次数配额
示例:999850
X-RateLimit-Reset
integer
日配额重置 Unix 秒级时间戳(北京时间次日 0 点)
示例:1795881600
响应字段
字段类型说明
object
string
可选值:list
data
array<object>
└id
string
模型名称
└object
string
可选值:model
└created
integer
上架 Unix 秒级时间戳
└owned_by
string
示例:heimori
响应示例
200 响应
{
  "object": "list",
  "data": [
    {
      "id": "tengri-2-max",
      "object": "model",
      "created": 1700000000,
      "owned_by": "heimori"
    }
  ]
}

代码示例

curl -X GET "https://cloud.heimori.cn/compatible-mode/v1/models" \
  -H "Authorization: Bearer sk-heimori-..."

DashScope 兼容基址查询单个模型信息

GET/compatible-mode/v1/models/{model}

按模型名查询单个模型的可用状态与基础元数据;若不存在返回 404 model_not_found。

请求参数

参数类型说明
modelpath必填
string
模型名称
示例:tengri-2-max

响应

HTTP 200application/json模型对象
响应头
响应头类型说明
X-Request-Id
string
本次请求唯一追踪 ID,排查问题与账单核对时提供
示例:a3f5c8e2-91b4-4d7a-8e62-1f90c3b8e412
X-RateLimit-Remaining
integer
当日剩余调用次数配额
示例:999850
X-RateLimit-Reset
integer
日配额重置 Unix 秒级时间戳(北京时间次日 0 点)
示例:1795881600
响应字段
字段类型说明
id
string
模型名称
object
string
可选值:model
created
integer
上架 Unix 秒级时间戳
owned_by
string
示例:heimori
响应示例
200 响应
{
  "id": "tengri-2-max",
  "object": "model",
  "created": 1700000000,
  "owned_by": "heimori"
}

代码示例

curl -X GET "https://cloud.heimori.cn/compatible-mode/v1/models/tengri-2-max" \
  -H "Authorization: Bearer sk-heimori-..."

DashScope 兼容基址文本续写

POST/compatible-mode/v1/completions

兼容 OpenAI Legacy POST /v1/completions 文本续写协议。

基址与鉴权:统一使用 https://cloud.heimori.cn/v1, 请求头携带 Authorization: Bearer <API Key>(亦支持 api-key 或 x-api-key 请求头)。

可选模型(单价见官网「Tengri AI 模型价格」):tengri-2-max / tengri-2 / tengri-2-fast / tengri-2-pro / tengri-t1 / tengri-t1-pro

请求参数application/json

参数类型说明
model必填
string
模型名,当前可选:tengri-2-max / tengri-2 / tengri-2-fast / tengri-2-pro / tengri-t1 / tengri-t1-pro
可选值:tengri-2-maxtengri-2tengri-2-fasttengri-2-protengri-t1tengri-t1-pro
示例:tengri-2-max
prompt必填
string
续写提示文本
max_tokens可选
integer
最大输出 token 数
示例:256
temperature可选
number
采样温度
top_p可选
number
核采样概率阈值
n可选
integer
候选续写条数
默认值:1
stream可选
boolean
是否以 SSE 流式返回
默认值:false
stop可选
string
停止词
echo可选
boolean
是否回显 prompt
默认值:false
suffix可选
string
续写后追加后缀
presence_penalty可选
number
frequency_penalty可选
number
seed可选
integer
user可选
string

响应

HTTP 200application/jsonOpenAI 兼容的 text_completion 对象
响应头
响应头类型说明
X-Request-Id
string
本次请求唯一追踪 ID,排查问题与账单核对时提供
示例:a3f5c8e2-91b4-4d7a-8e62-1f90c3b8e412
X-RateLimit-Remaining
integer
当日剩余调用次数配额
示例:999850
X-RateLimit-Reset
integer
日配额重置 Unix 秒级时间戳(北京时间次日 0 点)
示例:1795881600
响应字段
字段类型说明
id
string
object
string
可选值:text_completion
created
integer
model
string
choices
array<object>
└text
string
└index
integer
└logprobs
object | null
└finish_reason
string
可选值:stoplengthcontent_filter
usage
object
└prompt_tokens
integer
└completion_tokens
integer
└total_tokens
integer
响应示例
200 响应
{
  "id": "cmpl-20261128001",
  "object": "text_completion",
  "created": 1795853000,
  "model": "tengri-2-max",
  "choices": [
    {
      "text": "自上而下竖排书写,行序从左向右排列。",
      "index": 0,
      "logprobs": null,
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 12,
    "completion_tokens": 20,
    "total_tokens": 32
  }
}
另支持非 JSON 响应格式:text/event-stream

代码示例

curl -N -X POST "https://cloud.heimori.cn/compatible-mode/v1/completions" \
  -H "Authorization: Bearer sk-heimori-..." \
  -H "Accept: text/event-stream" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "tengri-2-max",
  "prompt": "传统蒙古文的书写特点是:"
}'

DashScope 兼容基址模型响应(Responses API)

POST/compatible-mode/v1/responses

兼容 OpenAI Responses API(POST /v1/responses),可直接配合新版 OpenAI SDK client.responses.create() 调用。

基址与鉴权:统一使用 https://cloud.heimori.cn/v1, 请求头携带 Authorization: Bearer <API Key>(亦支持 api-key 或 x-api-key 请求头)。

可选模型(单价见官网「Tengri AI 模型价格」):tengri-2-max / tengri-2 / tengri-2-fast / tengri-2-pro / tengri-t1 / tengri-t1-pro

请求参数application/json

参数类型说明
model必填
string
模型名,当前可选:tengri-2-max / tengri-2 / tengri-2-fast / tengri-2-pro / tengri-t1 / tengri-t1-pro
可选值:tengri-2-maxtengri-2tengri-2-fasttengri-2-protengri-t1tengri-t1-pro
示例:tengri-2-max
input必填
string
输入文本字符串或 Responses 条目数组
instructions可选
string
系统指令(可选)
stream可选
boolean
true 时以 SSE 流式返回事件流
默认值:false
max_output_tokens可选
integer
限制最大输出 token 数
temperature可选
number
采样温度
top_p可选
number
核采样概率阈值
tools可选
array<object>
函数工具定义列表
tool_choice可选
string
工具调用策略
可选值:autononerequired
parallel_tool_calls可选
boolean
默认值:true
text可选
object
结构化输出格式配置(text.format)
user可选
string
调用方终端用户标识
metadata可选
object

响应

HTTP 200application/jsonOpenAI Responses 格式对象
响应头
响应头类型说明
X-Request-Id
string
本次请求唯一追踪 ID,排查问题与账单核对时提供
示例:a3f5c8e2-91b4-4d7a-8e62-1f90c3b8e412
X-RateLimit-Remaining
integer
当日剩余调用次数配额
示例:999850
X-RateLimit-Reset
integer
日配额重置 Unix 秒级时间戳(北京时间次日 0 点)
示例:1795881600
响应字段
字段类型说明
id
string
object
string
可选值:response
created_at
integer
status
string
可选值:completedincompletefailed
model
string
output
array<object>
usage
object
└input_tokens
integer
└output_tokens
integer
└total_tokens
integer
响应示例
200 响应
{
  "id": "resp_20261128001",
  "object": "response",
  "created_at": 1795852900,
  "status": "completed",
  "model": "tengri-2-max",
  "output": [
    {
      "id": "msg_20261128001",
      "type": "message",
      "status": "completed",
      "role": "assistant",
      "content": [
        {
          "type": "output_text",
          "text": "ᠲᠠ ᠪᠦᠬᠦᠨ ᠳᠦ ᠮᠡᠨᠳᠦ ᠬᠦᠷᠭᠡᠶ᠎ᠡ᠃",
          "annotations": []
        }
      ]
    }
  ],
  "usage": {
    "input_tokens": 14,
    "output_tokens": 18,
    "total_tokens": 32
  }
}
另支持非 JSON 响应格式:text/event-stream

代码示例

curl -N -X POST "https://cloud.heimori.cn/compatible-mode/v1/responses" \
  -H "Authorization: Bearer sk-heimori-..." \
  -H "Accept: text/event-stream" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "tengri-2-max",
  "input": "用传统蒙古文写一句欢迎词"
}'

DashScope 兼容基址估算 Responses 输入 Token 数

POST/compatible-mode/v1/responses/input_tokens

估算 POST /v1/responses 输入文本与系统指令的 token 数;本接口不计费且在余额为 0 时可用。

请求参数application/json

参数类型说明
model必填
string
模型名,当前可选:tengri-2-max / tengri-2 / tengri-2-fast / tengri-2-pro / tengri-t1 / tengri-t1-pro
可选值:tengri-2-maxtengri-2tengri-2-fasttengri-2-protengri-t1tengri-t1-pro
示例:tengri-2-max
input必填
string
输入文本字符串或 Responses 消息数组
instructions可选
string
可选系统指令

响应

HTTP 200application/json估算的输入 token 数量
响应头
响应头类型说明
X-Request-Id
string
本次请求唯一追踪 ID,排查问题与账单核对时提供
示例:a3f5c8e2-91b4-4d7a-8e62-1f90c3b8e412
X-RateLimit-Remaining
integer
当日剩余调用次数配额
示例:999850
X-RateLimit-Reset
integer
日配额重置 Unix 秒级时间戳(北京时间次日 0 点)
示例:1795881600
响应字段
字段类型说明
object
string
可选值:response.input_tokens
input_tokens
integer
响应示例
200 响应
{
  "object": "response.input_tokens",
  "input_tokens": 18
}

代码示例

curl -X POST "https://cloud.heimori.cn/compatible-mode/v1/responses/input_tokens" \
  -H "Authorization: Bearer sk-heimori-..." \
  -H "Content-Type: application/json" \
  -d '{
  "model": "tengri-2-max",
  "input": "介绍一下传统蒙古文的历史演变"
}'

DashScope 兼容基址对话消息(Anthropic Messages)

POST/compatible-mode/v1/messages

兼容 Anthropic Messages API(POST /v1/messages),base_url 填 https://cloud.heimori.cn,支持 x-api-key 或 Authorization: Bearer。

可选模型(单价见官网「Tengri AI 模型价格」):tengri-2-max / tengri-2 / tengri-2-fast / tengri-2-pro / tengri-t1 / tengri-t1-pro

请求参数application/json

参数类型说明
anthropic-versionheader可选
string
Anthropic 协议版本头,推荐传 `2023-06-01`
示例:2023-06-01
model必填
string
模型名,当前可选:tengri-2-max / tengri-2 / tengri-2-fast / tengri-2-pro / tengri-t1 / tengri-t1-pro
可选值:tengri-2-maxtengri-2tengri-2-fasttengri-2-protengri-t1tengri-t1-pro
示例:tengri-2-max
max_tokens必填
integer
本次回复的最大输出 token 数
示例:1024
system可选
string
系统提示词
messages必填
array<object>
Anthropic 格式消息列表(role 仅支持 user / assistant)
示例:[{"role":"user","content":"介绍一下传统蒙古文的书写方向。"}]
stream可选
boolean
true 时以 Anthropic SSE 生命周期事件流返回
默认值:false
temperature可选
number
采样温度
top_p可选
number
核采样累计概率阈值
stop_sequences可选
array<string>
自定义停止词序列
tools可选
array<object>
Anthropic 格式工具定义列表
tool_choice可选
object
工具选择策略

响应

HTTP 200application/jsonAnthropic Messages 格式响应对象
响应头
响应头类型说明
X-Request-Id
string
本次请求唯一追踪 ID,排查问题与账单核对时提供
示例:a3f5c8e2-91b4-4d7a-8e62-1f90c3b8e412
X-RateLimit-Remaining
integer
当日剩余调用次数配额
示例:999850
X-RateLimit-Reset
integer
日配额重置 Unix 秒级时间戳(北京时间次日 0 点)
示例:1795881600
响应字段
字段类型说明
id
string
type
string
可选值:message
role
string
可选值:assistant
model
string
content
array<object>
stop_reason
string | null
可选值:end_turnmax_tokenstool_use
stop_sequence
string | null
usage
object
└input_tokens
integer
└output_tokens
integer
└cache_read_input_tokens
integer
响应示例
200 响应
{
  "id": "msg_20261128001",
  "type": "message",
  "role": "assistant",
  "model": "tengri-2-max",
  "content": [
    {
      "type": "text",
      "text": "传统蒙古文自上而下书写、列从左向右排列。"
    }
  ],
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "usage": {
    "input_tokens": 24,
    "output_tokens": 28
  }
}
另支持非 JSON 响应格式:text/event-stream

代码示例

curl -N -X POST "https://cloud.heimori.cn/compatible-mode/v1/messages" \
  -H "Authorization: Bearer sk-heimori-..." \
  -H "Accept: text/event-stream" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "tengri-2-max",
  "max_tokens": 1024,
  "messages": [
    {
      "role": "user",
      "content": "介绍一下传统蒙古文的书写方向。"
    }
  ]
}'

DashScope 兼容基址统计 Anthropic 输入 Token 数

POST/compatible-mode/v1/messages/count_tokens

兼容 Anthropic POST /v1/messages/count_tokens,计算消息数组、系统提示词与工具定义的输入 token 数。本接口不计费。

请求参数application/json

参数类型说明
anthropic-versionheader可选
string
Anthropic 协议版本头,推荐传 `2023-06-01`
示例:2023-06-01
model必填
string
模型名,当前可选:tengri-2-max / tengri-2 / tengri-2-fast / tengri-2-pro / tengri-t1 / tengri-t1-pro
可选值:tengri-2-maxtengri-2tengri-2-fasttengri-2-protengri-t1tengri-t1-pro
示例:tengri-2-max
system可选
string
messages必填
array<object>
示例:[{"role":"user","content":"介绍一下传统蒙古文的书写方向。"}]
tools可选
array<object>

响应

HTTP 200application/json输入 token 统计结果
响应头
响应头类型说明
X-Request-Id
string
本次请求唯一追踪 ID,排查问题与账单核对时提供
示例:a3f5c8e2-91b4-4d7a-8e62-1f90c3b8e412
X-RateLimit-Remaining
integer
当日剩余调用次数配额
示例:999850
X-RateLimit-Reset
integer
日配额重置 Unix 秒级时间戳(北京时间次日 0 点)
示例:1795881600
响应字段
字段类型说明
input_tokens
integer
响应示例
200 响应
{
  "input_tokens": 26
}

代码示例

curl -X POST "https://cloud.heimori.cn/compatible-mode/v1/messages/count_tokens" \
  -H "Authorization: Bearer sk-heimori-..." \
  -H "Content-Type: application/json" \
  -d '{
  "model": "tengri-2-max",
  "messages": [
    {
      "role": "user",
      "content": "介绍一下传统蒙古文的书写方向。"
    }
  ]
}'

查询额度上限与余额(根路径兼容别名)

GET/dashboard/billing/subscription

返回当前 API Key 所属云账户的可用余额与总额度上限(同时挂载于 /dashboard/billing/subscription)。本接口不计费。

请求参数

无请求参数

响应

HTTP 200application/json账户额度与人民币余额快照
响应头
响应头类型说明
X-Request-Id
string
本次请求唯一追踪 ID,排查问题与账单核对时提供
示例:a3f5c8e2-91b4-4d7a-8e62-1f90c3b8e412
X-RateLimit-Remaining
integer
当日剩余调用次数配额
示例:999850
X-RateLimit-Reset
integer
日配额重置 Unix 秒级时间戳(北京时间次日 0 点)
示例:1795881600
响应字段
字段类型说明
object
string
可选值:billing_subscription
has_payment_method
boolean
示例:true
soft_limit_usd
number
兼容额度数值(单位为元,保留协议字段名)
hard_limit_usd
number
兼容额度硬上限(同 soft_limit_usd)
system_hard_limit_usd
number
系统兼容额度硬上限(同 soft_limit_usd)
access_until
integer
当前密钥到期 Unix 秒级时间戳,0 表示无期限
balance_yuan
number
人民币可用额度(元)
响应示例
200 响应
{
  "object": "billing_subscription",
  "has_payment_method": true,
  "soft_limit_usd": 1500,
  "hard_limit_usd": 1500,
  "system_hard_limit_usd": 1500,
  "access_until": 0,
  "balance_yuan": 1280.5
}

代码示例

curl -X GET "https://cloud.heimori.cn/dashboard/billing/subscription" \
  -H "Authorization: Bearer sk-heimori-..."

查询当前密钥区间消费汇总(根路径兼容别名)

GET/dashboard/billing/usage

按可选 UTC 日期 start_date / end_date(YYYY-MM-DD)查询当前 API Key 在指定范围内的累计消费金额(同时挂载于 /dashboard/billing/usage)。本接口不计费。

请求参数

参数类型说明
start_datequery可选
string
UTC 起始日期(YYYY-MM-DD)
示例:2026-11-01
end_datequery可选
string
UTC 结束日期(YYYY-MM-DD)
示例:2026-11-30

响应

HTTP 200application/json当前 API Key 消费汇总
响应头
响应头类型说明
X-Request-Id
string
本次请求唯一追踪 ID,排查问题与账单核对时提供
示例:a3f5c8e2-91b4-4d7a-8e62-1f90c3b8e412
X-RateLimit-Remaining
integer
当日剩余调用次数配额
示例:999850
X-RateLimit-Reset
integer
日配额重置 Unix 秒级时间戳(北京时间次日 0 点)
示例:1795881600
响应字段
字段类型说明
object
string
可选值:list
total_usage
number
累计消费(分)
total_amount_yuan
number
累计消费(元)
响应示例
200 响应
{
  "object": "list",
  "total_usage": 21950,
  "total_amount_yuan": 219.5
}

代码示例

curl -X GET "https://cloud.heimori.cn/dashboard/billing/usage" \
  -H "Authorization: Bearer sk-heimori-..."

查询可用额度快照(根路径兼容别名)

GET/dashboard/billing/credit_grants

返回与 /v1/dashboard/billing/subscription 一致的账户额度与余额信息(同时挂载于 /dashboard/billing/credit_grants)。本接口不计费。

请求参数

无请求参数

响应

HTTP 200application/json账户额度与人民币余额快照
响应头
响应头类型说明
X-Request-Id
string
本次请求唯一追踪 ID,排查问题与账单核对时提供
示例:a3f5c8e2-91b4-4d7a-8e62-1f90c3b8e412
X-RateLimit-Remaining
integer
当日剩余调用次数配额
示例:999850
X-RateLimit-Reset
integer
日配额重置 Unix 秒级时间戳(北京时间次日 0 点)
示例:1795881600
响应字段
字段类型说明
object
string
可选值:billing_subscription
has_payment_method
boolean
示例:true
soft_limit_usd
number
兼容额度数值(单位为元,保留协议字段名)
hard_limit_usd
number
兼容额度硬上限(同 soft_limit_usd)
system_hard_limit_usd
number
系统兼容额度硬上限(同 soft_limit_usd)
access_until
integer
当前密钥到期 Unix 秒级时间戳,0 表示无期限
balance_yuan
number
人民币可用额度(元)
响应示例
200 响应
{
  "object": "billing_subscription",
  "has_payment_method": true,
  "soft_limit_usd": 1500,
  "hard_limit_usd": 1500,
  "system_hard_limit_usd": 1500,
  "access_until": 0,
  "balance_yuan": 1280.5
}

代码示例

curl -X GET "https://cloud.heimori.cn/dashboard/billing/credit_grants" \
  -H "Authorization: Bearer sk-heimori-..."