Baiyun API tutorial: Responses text interface
Responses 同步与 SSE 流式文本请求及完整上下文说明。 附完整检查步骤、实操验证和错误处理。
Responses 文本接口
Interface Address:POST https://api.baiyun.si/v1/responses。
适合明确支持 Responses 协议的应用。当前可使用同步和 SSE 流式文本请求;完整接口的工具、文件、图像等扩展功能暂未开放。
同步文本请求
curl --fail-with-body https://api.baiyun.si/v1/responses \
-H "Authorization: Bearer $BAIYUN_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model":"gpt-6-luna",
"input":"请用一句话介绍你能帮我做什么。",
"stream":false
}'
响应中的 output 数组包含输出项。读取消息项 content 中 type 为 output_text 的 text 字段,并保留 usage 用量信息。不要假设原始 REST JSON 一定存在 SDK 提供的便利字段 output_text。
SSE 流式请求
curl --no-buffer --fail-with-body https://api.baiyun.si/v1/responses \
-H "Authorization: Bearer $BAIYUN_API_KEY" \
-H 'Content-Type: application/json' \
-d '{"model":"gpt-6-luna","input":"请写两句普通的问候语。","stream":true}'
按 SSE 事件类型解析:response.output_text.delta 提供文本增量;完整结束时应收到 response.completed。流未完成、出现失败事件或网络中断时,不应把已经显示的部分内容当成完整响应。
提交完整文本历史
{
"model": "gpt-6-luna",
"instructions": "用中文简短回答。",
"input": [
{"role": "user", "content": "什么是 Token?"},
{"role": "assistant", "content": "Token 是模型处理文本时使用的计量单位。"},
{"role": "user", "content": "它与字数完全相同吗?"}
],
"stream": false
}
当前应把必要上下文以文本随本次请求提交。引用上游会话的 previous_response_id、外部历史、工具调用或不可检查的媒体载荷暂不开放。
使用前核对
- 先通过带 Bearer 鉴权的
/v1/models核对实际模型名称。 - 当前仅开放文本模式,不支持任意 Responses 扩展字段或 SDK 自动附加的工具功能。
max_output_tokens等参数不是已保证的输出或费用硬上限;按实际用量和消费记录核对费用。- 每凭据最多 2 个并发请求;遇限流先等待,避免自动无限重试。
完整政策和暂未开放范围见本站使用规则;Chat 客户端查看Chat 文本接口。
Checklist before practical use
- Prepare your own account and access keys, and do not use others' shared credentials.
- Records client versions, systems, and models to be used for easy reproduction during troubleshooting.
- Save the original configuration or screenshot, hide keys, verification codes, and private content.
- Confirm that testing may consume a small amount of DK, starting with a single sentence and a single request.
- Review the current model plaza and status page before deciding whether to enable more features.
Detailed investigation: narrow down the scope of the problem in order
First, confirm that the account is complete, the key is valid, and the DK balance is sufficient, then verify the protocol, address, and model. Make a minimum text request using the same key; Only after it succeeds does it restore attachments, tools, or automatically retry each item. After saving the client configuration, reopen the session to avoid using the previous vendor in the old session.
How to confirm that this section has been learned
Don't just check the "Configuration saved successfully" prompt. You should be able to clearly state the current Base URL, key usage, chosen model, and request protocol, and be able to verify your operation results on the corresponding console. The client-side tutorial uses a single actual plain text response and corresponding logs as the initial completion standard; Account tutorials are based on comprehensive security information; The billing tutorial uses the correspondence between principal, channel fees, and DK as the standard.
If an error occurs, record the occurrence time, HTTP status, content of the anonymized error, and the actual expected result. Do not screenshot the entire page key, and do not give the password or verification code to others. For 401, authentication should be resolved first; for 400, parameters should be resolved first; for 429, intensive retries should be stopped; for 404, request paths and upstream verification should be verified; recharging cannot resolve all errors.
A small task suitable for practice
Complete the minimum steps in this section in your own testing environment, recording in text "how you originally set it, which item you modified, and what results you saw." Do not treat production data, real payments, or irrecoverable commands as exercises. If you encounter features beyond what this section offers, first check the corresponding protocol tutorial before considering adding features; Changing only one configuration at a time makes it easy to judge which step leads to errors.
The next step is the boundary of the version
Return to the full learning map · Streamlined API site configuration · Real-time status of this site。
The tutorial was compiled on October 9, 2026. The specific interface and capabilities may vary depending on the client and upstream versions; The configuration guidelines do not mean that all client versions have passed the test. For balance payments, QQ / Alipay login, and open channels, please refer to the actual page page; Compression interfaces: Previously, upstream 404 and raw image channels were not available, so don't assume configuration files can be automatically removed.