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.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.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 |
reasoning output entry format of the Responses API.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."}'
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 | |
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 | |
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. |
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. |
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.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 field supports two forms.{"model": "glm-5.2","input": "Hello, please introduce yourself."}
role set to user.input is an array, each element is an input entry.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. |
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 |
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. |
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 Type | type Value | Description |
Function tool | function | Fully supported, with the name, description, parameters, and strict fields all available. |
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. |
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 |
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 | |
output_text | String | A convenience field, which is the concatenated result of all text content blocks in output. |
usage | Object | |
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. |
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 array is arranged in the actual generation order of reasoning, messages, and function calls.{"type": "reasoning","id": "rs_xxx","status": "completed","summary": [{"type": "summary_text","text": "Reasoning process text"}]}
{"type": "message","id": "msg_xxx","status": "completed","role": "assistant","content": [{"type": "output_text","text": "Reply text generated by the model","annotations": []}]}
content array support two types: output_text (text generated by the model) and refusal (reason text when the model refuses to reply).{"type": "function_call","id": "fc_xxx","status": "completed","call_id": "call_xxx","name": "get_weather","arguments": "{\\"location\\":\\"Beijing\\",\\"unit\\":\\"celsius\\"}"}
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.{"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. |
output_tokens and output_tokens_details.reasoning_tokens, which affects the total Token consumption for this call.stream: true is set, the response is streamed back via Server-Sent Events (SSE).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.
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 | 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. |
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?"},]}
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 output entry of the Responses API. Callers do not need to concern themselves with differences in the underlying return formats.reasoning_content field.reasoning.effort to none or no_think:{"model": "glm-5.2","input": "Hello","reasoning": {"effort": "none"}}
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."}'
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."}'
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"}'
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"]}}]}'
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}'
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}}}'
json_schema output format is used, it is recommended to include "additionalProperties": false in the schema to achieve better model compatibility.model to the corresponding model ID to invoke it normally. TokenHub automatically performs protocol conversion. For details, see Usage Instructions.previous_response_id Return an Error?input array. For details, see Multi-turn Conversation Instructions.web_search,code_interpreter Not Taking Effect?function-type tools are supported. Other built-in tool types are automatically discarded without error. For details, see Tool Call Support Scope.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.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.Esta página foi útil?
Você também pode entrar em contato com a Equipe de vendas ou Enviar um tíquete em caso de ajuda.
comentários