Skip to Content

Responses

POST https://api.fenno.ai/v1/responses Authorization: Bearer <FENNO_API_KEY> Content-Type: application/json

选择支持 Responses 的模型与路由。端点存在不意味着支持 OpenAI 托管工具或全部响应存储功能。

请求字段

字段类型含义
modelstring,必填精确的 Responses 可用模型 ID
inputstring 或 array文本或类型化输入项
instructionsstring,可选顶层系统/开发者指令
streamboolean返回类型化 SSE 事件
max_output_tokensinteger,可选依模型支持情况设置的输出上限
tools、tool_choicearray / string 或 objectResponses 工具格式及选择策略
text.formatobject,可选输出格式,包括受支持的 JSON Schema
reasoningobject,可选模型支持的推理配置

不能直接替换为 Chat 的 messages、嵌套函数定义或 response_format。

Python 示例

安装 openai,设置 FENNO_API_KEY 以及支持 Responses 的 FENNO_MODEL:

import os from openai import OpenAI client = OpenAI( base_url="https://api.fenno.ai/v1", api_key=os.environ["FENNO_API_KEY"], timeout=60.0, max_retries=0, ) response = client.responses.create( model=os.environ["FENNO_MODEL"], instructions="Answer concisely.", input="What is an API gateway?", ) print(response.status) print(response.output_text)

output_text 是 SDK 汇总文本的便捷属性。直接解析 HTTP JSON 时,应遍历 output[] 的类型与内容,不要假设原始 JSON 顶层存在 output_text。

输出与对话历史

响应包含 id、status、类型化 output 项,以及服务提供时的 usage。应处理 incomplete 和失败状态,而不是把“有文本”直接当作完整成功。

手动维护对话时,将相关 response.output 项追加到输入历史,再加入下一条用户消息或工具结果。模型需要的推理及其他非文本项也应保留;下一次请求所需的 instructions 仍要明确设置。

没有单独验证当前路由行为前,不要依赖 previous_response_id、响应存储查询或 conversation 状态。本指南采用明确传递历史的方式,不承诺托管状态能力。

函数工具

Responses 的函数字段直接放在工具对象中:

{ "type": "function", "name": "lookup_order", "description": "Look up an order the current user is allowed to access.", "parameters": { "type": "object", "properties": {"order_id": {"type": "string"}}, "required": ["order_id"], "additionalProperties": false } }

返回的 function_call 包含 name、JSON 字符串形式的 arguments 和 call_id。应用校验权限及参数、执行受允许工具后,通过输入项回传:

{"type":"function_call_output","call_id":"<CALL_ID>","output":"{\"status\":\"shipped\"}"}

使用模型返回的真实 call_id,不要使用响应 ID;同时保留相关输出历史并执行应用自己的权限检查。

流式事件

常见事件包括 response.created、response.output_text.delta、response.output_item.done 与 response.completed。函数参数增量独立于文本;需要明确处理 response.incomplete、response.failed 和 error,不能仅用 Chat Completions 的 [DONE] 判断成功。

继续阅读结构化输出、工具调用和官方 Responses 迁移说明 。