A specific engineering scenario
You are developing a customer service agent and need the model to output a structured JSON response that contains intent, entities, and response text. You called POST /v1/chat/completions, but the returned data is always mixed with newlines, indentations, and redundant keys. You need to write a lot of regular rules to clean it. Even worse, when you want to add an external search tool to the user's ongoing conversation, the model output and the data returned by the tool are crowded together, and you can't tell which piece is generated by the model and which piece is returned by the tool.
The essence of the problem is: AI The output of the model does not have a standardized, machine-readable container. And Responses API appeared to solve this problem.
Responses API What exactly does it mean?
Responses API is a set of conventions: it defines that model output should be packaged into a structured Response object, containing clear metadata (such as token usage, completion reason, tool call record) and content blocks distinguished by type (such as text block, tool call block, image block). It is not a specific HTTP endpoint, but a design pattern that is currently mainly driven by OpenAI in evolved versions of the Assistants API and Chat Completions API, and is also partially followed by the Anthropic-compatible Message API and Cohere's Chat API.
At the code level, a typical Responses API return structure is as follows:

{
"id": "resp_abc123",
"object": "response",
"created": 1712345678,
"model": "gpt-4-turbo",
"choices": [
{
"index": 0,
"finish_reason": "stop",
"message": {
"role": "assistant",
"content": [
{"type": "text", "text": "您好,请问有什么可以帮您?"},
{"type": "function_call", "name": "search_knowledge_base", "arguments": "{\"query\": \"退款流程\"}"}
]
}
}
],
"usage": {
"prompt_tokens": 100,
"completion_tokens": 50,
"total_tokens": 150
}
}
注意这里的 content 是一个数组,每种类型(文本、工具调用、图片等)都独立成块。这种设计使得你不再需要猜测模型输出里哪部分是自然语言、哪部分是工具触发器。
为什么 Responses API 突然成为热词
有三个推动力:
- 多模态输出的需求爆发。单一文本输出已经不够用了。模型同时返回文本和图片、文本和表格、文本和函数调用变得越来越常见。Responses API 通过 content 数组自然容纳了多种输出类型。
- Agent 工作流的标准化压力。当模型需要调用外部工具时,如何区分“模型自己的思考过程”和“工具返回的结果”成了痛点。Responses API 明确分离了模型消息和工具消息,使得 agent 循环更容易实现(例如 OpenAI 的
submit_tool_outputs)。 - 成本透明度要求。企业用户对 token 用量的精确核算需求强烈。Responses API 在每个响应里都包含准确的
usagedata, no additional calculations required.
If you wrote a simple chatbot using the Chat Completions API in 2023, you probably didn't notice the change in the output structure - because at that time the model only returned text. But today, nearly all production-grade AI applications are responding with multiple content blocks.

The most common place to be misunderstood or done wrong
Misunderstanding 1: Responses API = Streaming API
This is the most common confusion. Streaming API (such as SSE) is the transmission method, and Responses API is the data format definition. Streaming can be implemented on top of Responses API, for example to return content blocks block by block. However, many developers try to manually splice response objects after enabling streaming, and as a result lose token statistics or tool call IDs. Correct approach: Use the SDK’s built-in streaming parsing and do not handle chunk boundaries yourself.
Misunderstanding 2: Responses API from all model manufacturers are compatible
The fact is that various vendors have differences in the type naming and metadata fields of content blocks. For example, OpenAI uses function_call, Anthropic uses tool_use, and Cohere uses tool_calls. An adaptation layer is required during migration. A common failure scenario is that the response of OpenAI is directly passed to the agent framework of Anthropic, causing the tool call parsing to fail.
Misunderstanding 3: Responses API can solve all output parsing problems
Not really. Responses API only guarantees the agreement of the data structure, but does not guarantee that the model output completely conforms to your schema. For example, if you request JSON format, the model may still return illegal characters. At this point you still need an additional layer of validation (such as Pydantic or Zod parsing + error correction).
Actual pitfall cases
After a team migrated to Responses API, they found that the arguments field of the function was always truncated. After investigation, it was found that the HTTP client has a 2MB size limit for JSON by default, and the tool call parameters (including image base64) returned by the model exceeded this threshold. The solution is to adjust the client's max_payload_size configuration and enable response compression.
If you want to start practicing now, what should be the first step?
- Confirm that the model version you are using supports Responses API. OpenAI's gpt-4-turbo-preview and above, Anthropic's claude-3 series, and Cohere's command-r series all support similar structures. Use the latest SDK version.
- Enable experiments flag (if required). Some platforms, such as Azure OpenAI, require passing the
api-versionparameter to enable content blocks. - Rewrite your parsing logic. If you directly fetched the
choices[0].message.contentstring before, now you need to traverse thecontentarray and process it according to thetypebranch. - Add content block type verification. Define enumeration types (TextBlock, ToolCallBlock, etc.) in code and don't assume return types.
- Add unit test. Simulate responses for different types to ensure the parser correctly handles edge cases (e.g. empty array, unknown type).
After learning the basics, which engineering path should you go to next?
Now that you understand how Responses API normalizes model output, the next natural question is: how to build a complete agent workflow based on it? Specifically include:
- Tool Orchestration: How to convert function definitions into model-recognizable function/tool descriptions, and correctly handle loops of multiple tool calls.
- Context Management and Memory: How the
messagesarray of Responses API is expanded into a persistent session to avoid token overflow. - Evals and Tests: How to write Assertions for multi-content block responses to verify that tool calls fire as expected.
- Cost Tracking: Build a metering system based on
usagedata, supporting billing at the user or session level.
If you find that these directions are the bottlenecks in your work, then you are ready to transition from "calling APIs" to "designing AI systems."

No comments yet. Be the first to share your thoughts.