调用前准备
在已开通的企业空间取得接口地址和测试密钥。在运行命令的终端设置 AGENTOS_BASE_URL(完整 Base URL,包含版本前缀,末尾不加斜杠)和 AGENTOS_API_KEY。将 MODEL_ID 替换为同一密钥调用 GET /models 返回的模型 ID。 本例使用 chat 模型。
最小请求
在终端执行,按该模型在企业空间的开放范围及计费方式处理请求。
curl --fail-with-body -sS "$AGENTOS_BASE_URL/responses" \
-H "Authorization: Bearer $AGENTOS_API_KEY" -H "Content-Type: application/json" \
-d '{"model":"MODEL_ID","instructions":"用中文作答。","input":"请回复收到。"}'区分输出项
在 output 中找到 type 为 message 的项,再取 content 里的 output_text。 下列 JSON 只展示要检查的字段,文本、标识、用量均为示意。
{
"output": [
{
"type": "message",
"content": [
{
"type": "output_text",
"text": "收到。"
}
]
}
]
}兼容范围与常见问题
流式模式按 response.created、response.output_text.delta、response.completed 处理。当前不保留会话,传 previous_response_id、conversation 或 background: true 会收到 400。