tencent cloud

Responses API Compatibility Mode

Download
Mode fokus
Ukuran font
Terakhir diperbarui: 2026-07-15 14:40:16

Overview

The large language model service platform TokenHub (hereinafter referred to as "TokenHub") uniformly provides the OpenAI Responses API (POST /v1/responses) interface. For language models that natively support only the Chat Completions protocol, TokenHub automatically performs protocol conversion on the server side. Upon receiving a Responses API request, it converts the request into a Chat Completions request to call the model. It then converts the Chat Completions response (including streaming events) returned by the model into the Responses API format and returns it.
This conversion process is transparent to the caller. You do not need to be aware of the protocol actually used by the underlying model; you only need to uniformly use the Responses API for calls. Due to design differences between the two protocols, some Responses API parameters and capabilities (such as previous_response_id and built-in tools) are not supported or have behavioral restrictions in compatibility mode. For details, see the relevant sections in this document.
Currently, this compatibility mode supports the following models:
Model Name
Model ID
GLM-5.2
glm-5.2
DeepSeek-V4-Flash (Vendor Direct)
deepseek-v4-flash-202605
DeepSeek-V4-Pro (Vendor Direct)
deepseek-v4-pro-202606
DeepSeek-V4-Flash
deepseek-v4-flash
DeepSeek-V4-Pro
deepseek-v4-pro

Use Cases

You have built an application based on the Responses API and now want to directly call models supported by the compatibility mode, without needing to additionally integrate the Chat Completions protocol.
You need to use the model's own reasoning (thinking) capabilities and want to obtain the reasoning process in the unified reasoning output entry format of the Responses API.

Usage

The invocation method is identical to the standard Responses API, requiring no additional parameters or configuration: TokenHub automatically performs protocol conversion for models supported by the compatibility mode.
curl https://tokenhub-intl.tencentcloudmaas.com/v1/responses \\
-H "Content-Type: application/json" \\
-H "Authorization: Bearer $API_KEY" \\
-d '{
"model": "glm-5.2",
"input": "Please introduce quantum computing in three sentences."
}'
For basic information such as the Base URL, regional access addresses, and authentication methods, see the API Usage Guide.

Request Parameters

The following parameters are categorized into three types based on their support level: fully supported, not supported (returns an error), and accepted but not effective. Before making a call, confirm the actual support status of the parameters you use.

Fully Supported Parameters

Parameter
Type
Required
Description
model
String
Yes
Model ID.
input
String or Array
Yes
Input content. Supports a plain string or an array of input entries. For details, see Input Format Specification.
instructions
String
No
System instructions.
stream
Boolean
No
Whether to return in streaming mode. For details, see Streaming Output.
max_output_tokens
Integer
No
The maximum number of output tokens. Must be greater than 0.
temperature
Float
No
Sampling temperature. Value range: [0, 2].
top_p
Float
No
Nucleus sampling parameter. Value range: [0, 1].
tools
Array
No
A list of tools. Only the function type is supported in compatibility mode. For details, see Tool Calling Support Scope.
tool_choice
String or Object
No
Tool selection policy.
parallel_tool_calls
Boolean
No
Whether to allow parallel tool calls.
text.format
Object
No
Output format. Supports text, json_object, and json_schema.
reasoning.effort
String
No
Reasoning effort. For details, see Reasoning Model Description.
metadata
Object
No
Key-value pair metadata. A maximum of 16 pairs. Key length must not exceed 64 characters. Value length must not exceed 512 characters. Will be echoed as-is in the response.
service_tier
String
No
Service tier. Optional values: auto, default, flex, scale, priority. Will be echoed in the response.
prompt_cache_key
String
No
Prompt cache key. Will be echoed in the response.
prompt_cache_retention
String
No
Prompt cache retention policy. Optional values: in_memory, 24h. Will be echoed in the response.
top_logprobs
Integer
No
Number of top log probabilities. Will be echoed in the response.
stream_options.include_usage
Boolean
No
Whether to return usage at the end in streaming mode. Enabled by default.
user
String
No
User identifier.

Unsupported Parameters

The following parameters are not supported in compatibility mode. Passing any of these parameters returns an HTTP 400 error:
Parameter
Error Message
Description
background=true
background mode is not supported in chat-compat mode
Background asynchronous operation mode is not supported.
background=true and stream=true
background and stream=true cannot be used together
Background mode and stream output are mutually exclusive.
previous_response_id (non-empty value)
previous_response_id is not supported in chat-compat mode
Continuing a conversation based on a historical response ID is not supported. Pass the complete conversation history through the input array. For details, see multi-turn conversations.
previous_response_id (empty string)
previous_response_id must not be empty string
Parameter value validation.
previous_response_id and conversation are both provided
previous_response_id and conversation cannot be used together
The two parameters are mutually exclusive.
prompt (when input is empty)
prompt template is not supported in chat-compat mode, please provide input directly
Prompt templates are not supported. Pass the content directly through input.
input is empty
input is required and must contain at least one message
input is a required parameter.
temperature exceeds [0, 2].
temperature must be between 0 and 2
Parameter value range validation.
top_p exceeds [0, 1].
top_p must be between 0 and 1
Parameter value range validation.
max_output_tokens ≤ 0
max_output_tokens must be greater than 0
Parameter value range validation.
service_tier invalid value
invalid service_tier value: xxx
Enumeration value validation.
prompt_cache_retention invalid value
invalid prompt_cache_retention value: xxx
Enumeration value validation.
Note:
background returns an error only when background=true is explicitly passed. If it is not passed or false is passed, it is accepted normally and echoed as-is in the response.

Accepted but Ineffective Parameters

The following parameters are accepted normally (without error) but do not take effect in practice:
Parameter
Description
truncation
Context truncation policy. In compatibility mode, truncation is not performed.
include
Request for returning additional fields. In compatibility mode, additional fields are not returned.
store
Response storage switch. In compatibility mode, responses are not stored.
conversation
Conversation management. Manage the conversation history yourself via the input array.
context_management
Automatic context management (such as automatic compression).
max_tool_calls
Maximum tool call quantity limit.
prompt (when input is not empty)
Prompt template.
moderation
Content moderation configuration.
reasoning.summary
Reasoning summary mode.

Input Format

The input field supports two forms.

String Input

{
"model": "glm-5.2",
"input": "Hello, please introduce yourself."
}
It is equivalent to a text message with role set to user.

Input Item Array

When input is an array, each element is an input entry.
Supported input entry types:
Entry Type
type Value
Description
Messages
message
Standard message input, supporting the user, assistant, system, and developer roles, with the developer role being equivalent to the system role.
Function call
function_call
The function call initiated by the model in the previous round.
Function call result
function_call_output
Tool execution result.
Reasoning
reasoning
Reasoning content from the previous round.
Custom tool call
custom_tool_call
The processing method is consistent with function_call.
Custom tool call result
custom_tool_call_output
The processing method is consistent with function_call_output.
Unsupported input entry types (will be automatically ignored):
Entry Type
type Value
Computer operation call
computer_call
Computer operation result
computer_call_output
File search call
file_search_call
Web search call
web_search_call

Message Content Type

The content field of a message-type entry supports a string or an array of content blocks. It supports the following content block types:
Content Block Type
type Value
Description
Text Input
input_text
Text content.
Text Output
output_text
Text content used for assistant messages.
Plain text
text
Compatible representation of text content.
Image Input
input_image
Supports image_url (remote URL or Base64 Data URI), and the detail field can be set to low, high, or auto.
File Input
input_file
Supported only when file_data (Base64-encoded content) is provided, and it will be converted to Data URI format and passed to the model.
Image input does not support referencing uploaded files via file_id. If passed, it will be ignored. File input only supports the form of inline file_data. File input that carries only file_id will also be ignored.

Tool Call Support Scope

Supported Tool Types

Tool Type
type Value
Description
Function tool
function
Fully supported, with the name, description, parameters, and strict fields all available.
Function Tool Field Description:
Field
Type
Required
Description
type
String
Yes
Fixed as function.
name
String
Yes
Name of the function
description
String
No
Description of the function, for the model to determine whether to call it.
parameters
Object
No
The JSON Schema for function parameters. Defaults to {"type": "object", "properties": {}} if not provided.
strict
Boolean
No
Whether to perform strict parameter validation.

Unsupported Tool Types

The following tool types are not currently supported in compatibility mode. If passed, they will be automatically discarded without error.
Tool Type
type Value
File search
file_search
Web search
web_search,web_search_preview
Code interpreter
code_interpreter
MCP tools
mcp
Computer operation
computer_use_preview,computer
Image generation
image_generation
Custom tools
custom
Shell tools
shell
Patch tools
apply_patch

Returned Result

Response Object

Non-streaming requests return a Response object. This object is also included in events such as response.created and response.completed for streaming requests. In the following example, output is an empty array. During actual invocation, it will be populated based on the model's output. For the specific structure, refer to the following sections and the invocation example.
{
"id": "resp_xxx",
"object": "response",
"created_at": 1751548800,
"status": "completed",
"model": "glm-5.2",
"output": [],
"output_text": "Text generated by the model",
"usage": {
"input_tokens": 20,
"output_tokens": 11,
"total_tokens": 31,
"input_tokens_details": {
"cached_tokens": 0
},
"output_tokens_details": {
"reasoning_tokens": 0
}
},
"metadata": {},
"error": null
}
Field
Type
Description
id
String
The unique identifier of the response.
object
String
Fixed as response.
created_at
Integer
The creation time of the response, a Unix timestamp (in seconds).
status
String
The status of the response. Possible values: completed, incomplete, failed.
model
String
The ID of the model actually invoked.
output
Array
A list of output entries. For details, see Output Entry Types.
output_text
String
A convenience field, which is the concatenated result of all text content blocks in output.
usage
Object
Token consumption statistics. For details, see Usage Consumption Statistics.
error
Object or null
Error information. It is null upon successful completion.
metadata
Object
Metadata echo, always returned (can be an empty object).
incomplete_details
Object or null
Details when the response is incomplete. The reason field takes the value max_output_tokens or content_filter. It is not returned upon successful completion.
If the following request parameters are passed, they will be echoed as-is in the response:
instructions
temperature
top_p
max_output_tokens
parallel_tool_calls
tool_choice
tools
reasoning
text
truncation
service_tier
prompt_cache_key
prompt_cache_retention
top_logprobs
background
prompt
max_tool_calls
-
-
-

Output Item Type

The output array is arranged in the actual generation order of reasoning, messages, and function calls.
Reasoning Entry:
{
"type": "reasoning",
"id": "rs_xxx",
"status": "completed",
"summary": [
{
"type": "summary_text",
"text": "Reasoning process text"
}
]
}
Message Entry:
{
"type": "message",
"id": "msg_xxx",
"status": "completed",
"role": "assistant",
"content": [
{
"type": "output_text",
"text": "Reply text generated by the model",
"annotations": []
}
]
}
The content blocks in the content array support two types: output_text (text generated by the model) and refusal (reason text when the model refuses to reply).
Function Call Entry:
{
"type": "function_call",
"id": "fc_xxx",
"status": "completed",
"call_id": "call_xxx",
"name": "get_weather",
"arguments": "{\\"location\\":\\"Beijing\\",\\"unit\\":\\"celsius\\"}"
}
Attention:
function_call.arguments is always in JSON string format. The caller must parse the JSON before using it. When submitting function execution results, include the corresponding call_id for that function call in the function_call_output entry.

Usage Statistics

{
"input_tokens": 20,
"output_tokens": 11,
"total_tokens": 31,
"input_tokens_details": {
"cached_tokens": 0
},
"output_tokens_details": {
"reasoning_tokens": 0
}
}
Field
Type
Description
input_tokens
Integer
The number of input tokens.
output_tokens
Integer
The number of output tokens, including reasoning tokens.
total_tokens
Integer
The total number of input and output tokens.
input_tokens_details.cached_tokens
Integer
The number of input tokens hit by the cache. It is 0 when there is no cache hit.
output_tokens_details.reasoning_tokens
Integer
The number of tokens consumed by the reasoning process. It is 0 when there is no reasoning.
Attention:
Reasoning tokens are counted towards output_tokens and output_tokens_details.reasoning_tokens, which affects the total Token consumption for this call.

Streaming Output

After stream: true is set, the response is streamed back via Server-Sent Events (SSE).

Event Sequence

The response has been created.
response.in_progress The response is in progress.
[reasoning, optional]
response.output_item.added The reasoning entry has started.
response.reasoning_summary_part.added The reasoning summary part has started.
response.reasoning_summary_text.delta Reasoning text delta (multiple times)
response.reasoning_summary_text.done The reasoning text is complete.
response.reasoning_summary_part.done The reasoning summary part is complete.
response.output_item.done The reasoning entry is complete.
[message, optional]
response.output_item.added The message entry has started.
response.content_part.added The content block has started.
response.output_text.delta Text delta (multiple times)
response.output_text.done The text is complete.
response.content_part.done The content block is complete.
response.output_item.done The message entry is complete.
[function_call, multiple allowed]
response.output_item.added The function call entry has started.
response.function_call_arguments.delta Argument delta (multiple times)
response.function_call_arguments.done The arguments are complete.
response.output_item.done The function call entry is complete.
The response is complete and contains full usage information.
The reasoning and message entries are optional, and whether they appear depends on the model's actual output. When reasoning and message content alternate (reasoning, message, reasoning, message), the start and end events for each output entry are returned correctly and in order.

Event Type

Event type
Description
response.created
The response has been created.
response.in_progress
The response is in progress.
response.output_item.added
An output entry is added, containing output_index and item.
response.output_item.done
The output entry is completed, containing output_index and item.
response.content_part.added
The content part is started, containing item_id, output_index, content_index, and part.
response.content_part.done
The content part is completed, containing item_id, output_index, content_index, and part.
response.output_text.delta
Text delta, containing item_id, output_index, content_index, and delta.
response.output_text.done
Text completed, containing item_id, output_index, content_index, and text.
response.reasoning_summary_part.added
Reasoning summary part started.
response.reasoning_summary_part.done
Reasoning summary part completed.
response.reasoning_summary_text.delta
Reasoning text delta.
response.reasoning_summary_text.done
Reasoning text completed.
response.function_call_arguments.delta
Function call arguments delta.
response.function_call_arguments.done
Function call arguments completed.
response.completed
The response is completed, containing the complete Response object and usage.
response.failed
The response failed, containing the Response object and error information.

Multi-Turn Conversation

In compatibility mode, previous_response_id is not supported. For multi-turn conversations, you must pass the complete conversation history through the input array:
{
"model": "glm-5.2",
"input": [
{"role": "user", "content": "My name is Xiaoming."},
{"role": "assistant", "content": "Hello, Xiaoming!"},
{"role": "user", "content": "What is the weather like today?"},
{"role": "assistant", "content": "I cannot directly obtain weather information, but I can query it for you."},
{"type": "function_call", "call_id": "call_1", "name": "get_weather", "arguments": "{\\"city\\":\\"Beijing\\"}"},
{"type": "function_call_output", "call_id": "call_1", "output": "{\\"temp\\":25,\\"weather\\":\\"Sunny\\"}"},
{"role": "assistant", "content": "It is 25 degrees Celsius and sunny in Beijing today."},
{"role": "user", "content": "What about tomorrow?"},
]
}
Attention:
The order of entries in the input array must align with the conversation timeline. The function_call and function_call_output must appear in pairs, and the call_id must match.

Reasoning Model Behavior

For models that support reasoning capabilities, the compatibility mode automatically handles the following two types of reasoning content return formats and uniformly converts them into the reasoning output entry of the Responses API. Callers do not need to concern themselves with differences in the underlying return formats.
The reasoning content returned by the model through the reasoning_content field.
For models that wrap reasoning content in specific tags within the main text, TokenHub automatically identifies and separates the reasoning content from the main answer.
To disable the reasoning process, set reasoning.effort to none or no_think:
{
"model": "glm-5.2",
"input": "Hello",
"reasoning": {
"effort": "none"
}
}

Call Example

Basic Text Conversation

curl https://tokenhub-intl.tencentcloudmaas.com/v1/responses \\
-H "Content-Type: application/json" \\
-H "Authorization: Bearer $API_KEY" \\
-d '{
"model": "glm-5.2",
"input": "Please introduce quantum computing in three sentences."
}'

Conversation with System Instructions

curl https://tokenhub-intl.tencentcloudmaas.com/v1/responses \\
-H "Content-Type: application/json" \\
-H "Authorization: Bearer $API_KEY" \\
-d '{
"model": "glm-5.2",
"instructions": "You are a professional translation assistant. Please translate user input into English.",
"input": "The weather is really nice today."
}'

Function Calling

Round 1: Define the tool and initiate the request.
curl https://tokenhub-intl.tencentcloudmaas.com/v1/responses \\
-H "Content-Type: application/json" \\
-H "Authorization: Bearer $API_KEY" \\
-d '{
"model": "glm-5.2",
"input": "What is the weather like in Beijing today?",
"tools": [
{
"type": "function",
"name": "get_current_weather",
"description": "Obtain the current weather for a specified location",
"parameters": {
"type": "object",
"properties": {
"location": {"type": "string", "description": "City name"},
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}
},
"required": ["location", "unit"]
}
}
],
"tool_choice": "auto"
}'
After the model returns a function call request, submit the execution result via function_call_output to obtain the final response:
curl https://tokenhub-intl.tencentcloudmaas.com/v1/responses \\
-H "Content-Type: application/json" \\
-H "Authorization: Bearer $API_KEY" \\
-d '{
"model": "glm-5.2",
"input": [
{"role": "user", "content": "What is the weather like in Beijing today?"},
{
"type": "function_call",
"call_id": "call_xxx",
"name": "get_current_weather",
"arguments": "{\\"location\\":\\"Beijing\\",\\"unit\\":\\"celsius\\"}"
},
{
"type": "function_call_output",
"call_id": "call_xxx",
"output": "{\\"temperature\\": 28, \\"unit\\": \\"celsius\\", \\"description\\": \\"Sunny\\"}"
}
],
"tools": [
{
"type": "function",
"name": "get_current_weather",
"description": "Obtain the current weather for a specified location",
"parameters": {
"type": "object",
"properties": {
"location": {"type": "string"},
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}
},
"required": ["location", "unit"]
}
}
]
}'

Streaming Output

curl https://tokenhub-intl.tencentcloudmaas.com/v1/responses \\
-H "Content-Type: application/json" \\
-H "Authorization: Bearer $API_KEY" \\
-d '{
"model": "glm-5.2",
"input": "Please write a poem about spring.",
"stream": true
}'

Structured Output

curl https://tokenhub-intl.tencentcloudmaas.com/v1/responses \\
-H "Content-Type: application/json" \\
-H "Authorization: Bearer $API_KEY" \\
-d '{
"model": "glm-5.2",
"input": "Extract the personal information from the following text: Zhang San, male, 25 years old, from Beijing.",
"text": {
"format": {
"type": "json_schema",
"name": "person_info",
"schema": {
"type": "object",
"properties": {
"name": {"type": "string"},
"gender": {"type": "string"},
"age": {"type": "number"},
"city": {"type": "string"}
},
"required": ["name", "gender", "age", "city"],
"additionalProperties": false
},
"strict": true
}
}
}'
When the json_schema output format is used, it is recommended to include "additionalProperties": false in the schema to achieve better model compatibility.

FAQs

What Changes Are Required to Migrate Existing Code Based on the Responses API to Models Supported in Compatibility Mode?

No changes are required. Simply set the model to the corresponding model ID to invoke it normally. TokenHub automatically performs protocol conversion. For details, see Usage Instructions.

Why Does Calling previous_response_id Return an Error?

In compatibility mode, continuing a conversation based on a historical response ID is not supported. You must instead pass the complete conversation history through the input array. For details, see Multi-turn Conversation Instructions.

Why Are Tools Such As web_search,code_interpreter Not Taking Effect?

In compatibility mode, only function-type tools are supported. Other built-in tool types are automatically discarded without error. For details, see Tool Call Support Scope.

How do I handle errors when tool_choice is set to required?

Support for required depends on whether the invoked model itself supports this value. Some models may not support it and return an error. It is recommended to use auto instead or directly specify the concrete tool name.

What happens when input is an empty string?

If the input is completely empty (containing neither a string nor any array elements), an HTTP 400 error is returned. If the content of a user message within the input is an empty string, the system automatically fills it with placeholder text to prevent model invocation exceptions.

Bantuan dan Dukungan

Apakah halaman ini membantu?

masukan