体验中心
体验中国电信星辰大模型效果
协议类型:OpenAI Responses
| 环境 | 地址 |
|---|---|
| 公网 | <https://openapi.teleagi.cn/aipaas/algo/v1/telechat-29b/v1/responses> |
POSTapplication/json采用 Bearer Token 鉴权,在请求头中携带 API Key:
Authorization: Bearer <用户申请的API-KEY>
| 请求头 | 说明 |
|---|---|
Authorization |
Bearer <API_KEY>,必填 |
session-id |
多轮对话场景下传入,不同 session 传入不同 session-id |
traceparent |
W3C Trace Context 链路追踪头,格式{version}-{trace-id}-{parent-id}-{flags},见下表 |
traceparent 字段说明:
| 字段 | 示例值 | 说明 |
|---|---|---|
version |
00 |
W3C 版本号,默认00 |
trace-id |
0af7651916cd43dd8448eb211c80319c |
32 位十六进制,整条链路唯一 ID |
parent-id |
b7ad6b7169203331 |
16 位十六进制,当前请求 span ID |
flags |
01 |
默认01 即可 |
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
model |
string | 是 | 固定值XingChen4-29B-A4B |
input |
string / array | 是 | 用户输入,可为纯文本或输入项数组(见 3.2) |
instructions |
string | 否 | 系统指令(等同 system prompt) |
max_output_tokens |
integer | 否 | 生成的最大 token 数 |
metadata |
object | 否 | 最多 16 组键值对的附加元数据 |
parallel_tool_calls |
boolean | 否 | 是否允许并行工具调用,默认true |
previous_response_id |
string | 否 | 关联上一轮响应 ID,用于多轮对话延续 |
prompt_cache_key |
string | 否 | 提示词缓存键(按小时计费) |
reasoning |
object | 否 | 推理配置(见 3.5) |
service_tier |
string | 否 | 服务层级 |
store |
boolean | 否 | 是否存储响应,默认true;多轮延续场景需为 true |
stream |
boolean | 否 | 是否流式返回,默认false |
temperature |
number | 否 | 采样温度,默认1 |
text |
object | 否 | 输出文本格式配置(见 3.6) |
tool_choice |
string / object | 否 | 工具调用策略(见 3.7) |
tools |
array | 否 | 工具定义数组,仅支持function 类型(见 3.4) |
top_p |
number | 否 | 核采样,范围0~`1,默认 1` |
top_logprobs |
integer | 否 | 每个 token 返回的备选概率数量,0~`20` |
logprobs |
boolean | 否 | 是否返回对数概率,默认false |
truncation |
string | 否 | 输入截断策略:auto / disabled |
user |
string | 否 | 终端用户唯一标识,用于监控与滥用检测 |
chat_template_kwargs |
object | 否 | 深度思考模式参数,传入{"enable_thinking": true} 启用深度思考 |
{
"model": "XingChen4-29B-A4B",
"input": [
{
"role": "user",
"content": "你好,一句话介绍一下你自己"
}
],
"instructions": "你是乐于助人的助手。",
"stream": true,
"max_output_tokens": 1024,
"temperature": 0.7,
"top_p": 0.9,
"text": { "format": { "type": "text" } },
"store": true
}
input[]| 类型 | 结构 | 说明 |
|---|---|---|
| 消息 | {"type":"message","role":"user","content":"..."} |
消息项,role 取 system/developer/user/assistant |
| 函数调用 | {"type":"function_call","call_id":"...","name":"...","arguments":"..."} |
助手已发出的函数调用 |
| 函数调用结果 | {"type":"function_call_output","call_id":"...","output":"..."} |
函数调用结果 |
| 项引用 | {"type":"item_reference","id":"..."} |
引用会话中已有的输出项 |
| 推理 | {"type":"reasoning","id":"...","summary":[...]} |
引用/携带推理摘要 |
消息内容块类型 input[].content[]:
| 类型 | 结构 | 说明 |
|---|---|---|
| 文本 | {"type":"input_text","text":"..."} |
文本 |
input为简单字符串时,等价于单个{"type":"message","role":"user","content":[{"type":"input_text","text":"..."}]}。
tools[](仅 function 类型)| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
type |
string | 是 | 固定为function |
name |
string | 是 | 函数名 |
description |
string | 否 | 函数描述 |
parameters |
object | 否 | JSON Schema 形式的参数定义 |
strict |
boolean | 否 | 是否启用严格结构化输出 |
reasoning| 字段 | 类型 | 说明 |
|---|---|---|
effort |
string | 推理强度:minimal / low / medium / high |
summary |
string | 推理摘要粒度:auto / concise / detailed |
text(输出格式)| 结构 | 说明 |
|---|---|
{"format":{"type":"text"}} |
默认文本 |
{"format":{"type":"json_object"}} |
JSON 对象输出 |
{"format":{"type":"json_schema","name":"...","schema":{...},"strict":true}} |
按 JSON Schema 约束输出 |
tool_choiceauto / none / required{"type":"function","name":"<函数名>"} 指定具体函数非流式返回:
{
"id": "resp_xxxxxxxx",
"object": "response",
"created_at": 1731691468,
"status": "completed",
"model": "XingChen4-29B-A4B",
"output": [
{
"type": "message",
"id": "msg_xxxxxxxx",
"role": "assistant",
"status": "completed",
"content": [
{
"type": "output_text",
"text": "你好!我是星辰大模型,由中电信人工智能科技研发。",
"annotations": []
}
]
}
],
"instructions": "你是乐于助人的助手。",
"parallel_tool_calls": true,
"usage": {
"input_tokens": 15,
"input_tokens_details": { "cached_tokens": 0 },
"output_tokens": 20,
"output_tokens_details": { "reasoning_tokens": 0 },
"total_tokens": 35
}
}
返回字段说明:
| 字段 | 类型 | 说明 |
|---|---|---|
id |
string | 响应唯一 ID |
object |
string | 固定为response |
created_at |
integer | 创建时间(Unix 秒级时间戳) |
status |
string | 响应状态(见下表) |
error |
object | 错误信息,含code 与 message |
incomplete_details |
object | 未完成原因,含reason |
instructions |
string | 系统指令 |
max_output_tokens |
integer | 最大输出 token 数 |
model |
string | 实际使用的模型 |
output |
array | 输出项数组(见下表) |
parallel_tool_calls |
boolean | 是否允许并行工具调用 |
previous_response_id |
string | 上一轮响应 ID |
reasoning |
object | 推理配置 |
store |
boolean | 是否存储响应 |
temperature |
number | 采样温度 |
text |
object | 输出文本格式 |
tool_choice |
string / object | 工具调用策略 |
tools |
array | 工具定义 |
top_p |
number | 核采样 |
top_logprobs |
integer | 备选概率数量 |
truncation |
string | 截断策略 |
usage |
object | token 用量 |
user |
string | 终端用户标识(可选) |
metadata |
object | 附加元数据 |
prompt_cache_key |
string | 提示词缓存键 |
status 取值:
| 值 | 说明 |
|---|---|
completed |
完成 |
in_progress |
进行中 |
failed |
失败 |
incomplete |
未完成(如因 token 上限截断) |
cancelled |
已取消 |
queued |
排队中 |
输出项类型 output[]:
| 类型 | 结构 | 说明 |
|---|---|---|
| 消息 | {"type":"message","id":"...","role":"assistant","content":[...]} |
助手消息 |
| 函数调用 | {"type":"function_call","id":"...","call_id":"...","name":"...","arguments":"..."} |
函数调用 |
| 推理 | {"type":"reasoning","id":"...","summary":[...]} |
推理摘要 |
消息输出内容块 output[].content[]:
| 类型 | 结构 | 说明 |
|---|---|---|
| 文本 | {"type":"output_text","text":"...","annotations":[]} |
文本回复 |
| 拒绝 | {"type":"refusal","refusal":"..."} |
拒绝说明 |
| 推理 | {"type":"reasoning","id":"...","summary":[...]} |
推理内容 |
usage 字段:
| 字段 | 类型 | 说明 |
|---|---|---|
input_tokens |
integer | 输入 token 数 |
input_tokens_details.cached_tokens |
integer | 命中缓存的输入 token 数 |
output_tokens |
integer | 输出 token 数 |
output_tokens_details.reasoning_tokens |
integer | 推理 token 数 |
total_tokens |
integer | 总 token 数 |
流式返回(SSE,stream=true):
event: response.created
data: {"type":"response.created","response":{...}}
event: response.in_progress
data: {"type":"response.in_progress","response":{...}}
event: response.output_item.added
data: {"type":"response.output_item.added","output_index":0,"item":{"type":"message","id":"msg_xxx","role":"assistant","status":"in_progress","content":[]}}
event: response.content_part.added
data: {"type":"response.content_part.added","output_index":0,"content_index":0,"part":{"type":"output_text","text":"","annotations":[]}}
event: response.output_text.delta
data: {"type":"response.output_text.delta","output_index":0,"content_index":0,"delta":"你好"}
event: response.output_text.done
data: {"type":"response.output_text.done","output_index":0,"content_index":0,"text":"你好!"}
event: response.content_part.done
data: {"type":"response.content_part.done","output_index":0,"content_index":0,"part":{"type":"output_text","text":"你好!","annotations":[]}}
event: response.output_item.done
data: {"type":"response.output_item.done","output_index":0,"item":{...}}
event: response.completed
data: {"type":"response.completed","response":{...}}
流式事件类型:
| 事件 | 说明 |
|---|---|
response.created |
响应创建 |
response.in_progress |
响应开始处理 |
response.output_item.added |
新增输出项 |
response.output_item.done |
输出项完成 |
response.content_part.added |
新增内容块 |
response.content_part.done |
内容块完成 |
response.output_text.delta |
文本增量 |
response.output_text.done |
文本完成 |
response.refusal.delta |
拒绝文本增量 |
response.refusal.done |
拒绝文本完成 |
response.reasoning_summary_part.added |
推理摘要块新增 |
response.reasoning_summary_part.done |
推理摘要块完成 |
response.reasoning_summary_text.delta |
推理摘要文本增量 |
response.reasoning_summary_text.done |
推理摘要文本完成 |
response.reasoning_text.delta |
推理文本增量 |
response.reasoning_text.done |
推理文本完成 |
response.function_call_arguments.delta |
函数参数增量 |
response.function_call_arguments.done |
函数参数完成 |
response.failed |
响应失败 |
response.completed |
响应完成 |
response.incomplete |
响应未完成 |
response.cancelled |
响应取消 |
error |
错误 |
curl --location '<https://openapi.teleagi.cn/aipaas/algo/v1/telechat-29b/v1/responses>' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <用户申请的API-KEY>' \
--data '{
"model": "XingChen4-29B-A4B",
"input": "你好,一句话介绍一下你自己",
"stream": true
}'
import requests
url = "<https://openapi.teleagi.cn/aipaas/algo/v1/telechat-29b/v1/responses>"
api_key = "<用户申请的API-KEY>"
payload = {
"model": "XingChen4-29B-A4B",
"input": "你好,一句话介绍一下你自己",
"stream": True,
}
resp = requests.post(
url,
headers={
"Content-Type": "application/json",
"Authorization": f"Bearer {api_key}",
},
json=payload,
stream=True,
)
# 流式解析 SSE(按 event / data 成对处理)
for line in resp.iter_lines(decode_unicode=True):
if not line:
continue
print(line)
import okhttp3.*;
import com.fasterxml.jackson.databind.ObjectMapper;
public class ResponsesExample {
public static void main(String[] args) throws Exception {
String url = "<https://openapi.teleagi.cn/aipaas/algo/v1/telechat-29b/v1/responses>";
String apiKey = "<用户申请的API-KEY>";
ObjectMapper mapper = new ObjectMapper();
String json = mapper.writeValueAsString(java.util.Map.of(
"model", "XingChen4-29B-A4B",
"input", "你好,一句话介绍一下你自己",
"stream", true
));
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url(url)
.addHeader("Content-Type", "application/json")
.addHeader("Authorization", "Bearer " + apiKey)
.post(RequestBody.create(json, MediaType.get("application/json")))
.build();
try (Response response = client.newCall(request).execute()) {
// 非流式:直接打印 body
System.out.println(response.body().string());
// 流式:通过 ResponseBody.source() 逐行读取 SSE
}
}
}