典名词元DMTOKENSHome
API DocumentationThird-Party Tools Tutorial
AI Model APIText

Text Generation (Responses)

POST/api/v1/responses

Header Parameters

Authorization*string

Use Bearer Token authentication. Format: Authorization: Bearer sk-xxxxxx

Request Body

application/json

model*string

Model name, example input: gpt-5.3-chat gpt-5.3-codex

input*string|array<object>

Model input supports the following formats: string: plain text, such as "Hello"; array: message array, arranged in conversational order.

instructions?string

Inserted as a system instruction at the beginning of the context. When using previous_response_id, the instructions specified in the previous turn are not passed into the current turn's context.

previous_response_id?string

The unique ID of the previous response. The current response ID is valid for 7 days. Use this parameter to create multi-turn conversations, where the server automatically retrieves and combines the input and output of the current turn as context. When both the input message array and previous_response_id are provided, new messages in input are appended to the historical context. Cannot be used simultaneously with conversation.

conversation?string

The conversation to which the current response belongs (refer to the Conversations API). History items in the conversation are automatically included as context for this request, and the input and output of this request will also be automatically added to the conversation once the response is complete. Cannot be used in conjunction with previous_response_id.

stream?boolean

Whether to enable streaming output. The default value is false. When set to true, model response data will be streamed to the client in real time.

store?boolean

Whether to store the model response generated in this session. The default value is true. false: Do not store. The conversation content cannot be used by previous_response_id and subsequent APIs. true: Store. The current model response can be used by previous_response_id and subsequent APIs.

tools?array<object>

An array of tools that the model can call when generating responses. Supports both built-in tools and custom function tools, which can be used in combination. For optimal response quality, it is recommended to enable the code_interpreter, web_search, and web_extractor tools simultaneously. web_search: A web search tool that allows the model to search for the latest information on the internet. Related documentation: Web Search. Properties: type string (Required). Fixed as web_search. Usage example: [{"type": "web_search"}]. web_extractor: A web extraction tool that allows the model to access and extract web page content. Currently, it must be used in conjunction with the web_search tool. qwen3-max and qwen3-max-2026-01-23 require thinking mode to be enabled simultaneously. Related documentation: Web Extraction. Properties: code_interpreter: A code interpreter tool that allows the model to execute code and return results, supporting data analysis. qwen3-max and qwen3-max-2026-01-23 require thinking mode to be enabled simultaneously. Related documentation: Code Interpreter. Properties: web_search_image: Searches for images based on text descriptions. Related documentation: Text-to-Image Search. Properties: type string (Required). Fixed as web_search_image. Usage example: [{"type": "web_search_image"}]. image_search: Searches for similar or related images based on an image; the input must include the image URL. Related documentation: Image-to-Image Search. Properties: type string (Required). Fixed as image_search. Usage example: [{"type": "image_search"}]. file_search: Searches within uploaded or associated knowledge bases. Related documentation: Knowledge Retrieval. Properties: type string (Required). Fixed as file_search. vector_store_ids array (Required). The ID of the knowledge base to retrieve. Currently, only one knowledge base ID is supported. Usage example: [{"type": "file_search", "vector_store_ids": ["your_knowledge_base_id"]}]. MCP Call: Calls external services via MCP (Model Context Protocol). Related documentation: MCP. Properties: type string (Required). Fixed as mcp. server_protocol string (Required). The communication protocol with the MCP service, such as "sse". server_label string (Required). The service label used to identify the MCP service. server_description string (Optional). The service description to help the model understand its functions and applicable scenarios. server_url string (Required). The URL of the MCP service endpoint. headers object (Optional). Request headers for carrying authentication and other information, such as Authorization. Usage example: mcp_tool = { "type": "mcp", "server_protocol": "sse", "server_label": "amap-maps", "server_description": "The Amap Maps MCP Server now covers 15 core interfaces, providing full-scenario geographic information services, including generating custom maps, navigating to destinations, hailing rides, geocoding, reverse geocoding, IP positioning, weather queries, cycling route planning, walking route planning, driving route planning, transit route planning, distance measurement, keyword search, nearby search, and detail search.", "server_url": "https://dashscope.aliyuncs.com/api/v1/mcps/amap-maps/sse", "headers": { "Authorization": "Bearer <your-mcp-server-token>" } } Custom function tool: A custom function tool that allows the model to call functions you define. When the model determines that a tool call is needed, the response will return an output of type function_call. Related documentation: Function Calling. Properties: type string (Required). Must be set to function. name string (Required). The tool name. Only letters, numbers, underscores (_), and hyphens (-) are allowed, up to 64 Tokens. description string (Required). The tool description to help the model determine when and how to call the tool. parameters object (Optional). The parameter description of the tool, which must be a valid JSON Schema. If the parameters argument is empty, it indicates that the tool has no input parameters (e.g., a time query tool). To improve the accuracy of tool calls, it is recommended to pass parameters. Usage example: [{ "type": "function", "name": "get_weather", "description": "Get weather information for a specified city", "parameters": { "type": "object", "properties": { "city": { "type": "string", "description": "City name" } }, "required": ["city"] } }]

[]?object
tool_choice?string|object

Controls how the model selects and calls tools. This parameter supports two assignment formats: string mode and object mode.

temperature?boolean

Sampling temperature controls the diversity of the text generated by the model. A higher temperature yields more diverse text, whereas a lower temperature yields more deterministic text. Value range: [0, 2). Both temperature and top_p can control the diversity of the generated text, so it is recommended to set only one of them.

top_p?number

The probability threshold for nucleus sampling, which controls the diversity of the text generated by the model. The higher the top_p, the more diverse the generated text; conversely, a lower value results in more deterministic text. Value range: (0, 1.0]. Both temperature and top_p can control the diversity of the generated text, so it is recommended to set only one of them.

enable_thinking?boolean

Whether to enable thinking mode. When enabled, the model will think before responding, and the thinking content will be returned via output items of the reasoning type. When thinking mode is enabled, it is recommended to enable built-in tools to achieve optimal model performance when handling complex tasks. Optional values: true: Enable; false: Disable.

reasoning?object

Control the model's reasoning effort. The model reasons before responding, and the reasoning content will be returned via output items of the reasoning type.

effort*string

Thinking intensity level, with the default value set to medium. none: disables thinking and responds directly. minimal: minimizes thinking for the fastest response. low: light thinking, focusing on fast response. medium (default): moderate thinking, balancing speed and thinking depth. high: deep thinking, focusing on handling complex professional issues. reasoning.effort takes precedence over enable_thinking; it is recommended to prioritize reasoning.effort, as enable_thinking will no longer be supported in the future.

Response Body

application/json

Success

TypeScript Definitions

Use the response body type in TypeScript.

id*string

The unique identifier for this call.

created_at*integer

The Unix timestamp of this request (in seconds).

object*string

Object type, fixed to response.

status*string

The status of response generation. Enum values: completed: Generation completed; failed: Generation failed; in_progress: Generation in progress; cancelled: Cancelled; queued: Request queued; incomplete: Generation incomplete.

model*string

The model ID used to generate the response.

output*array<object>

An array of output items generated by the model. The types and order of elements in the array depend on the model's response.

[]?object
type*string

Output item type. Enum values: message: Message type, containing the final reply content generated by the model. reasoning: Reasoning type, returned when reasoning.effort is set (not none) or thinking mode is enabled. Reasoning tokens are counted in output_tokens_details.reasoning_tokens and billed as reasoning tokens. function_call: Function call type, returned when a custom function tool is used. Requires processing the function call and returning the result. web_search_call: Web search call type, returned when the web_search tool is used. code_interpreter_call: Code execution type, returned when the code_interpreter tool is used. web_extractor_call: Web extraction type, returned when the web_extractor tool is used. Must be used in conjunction with the web_search tool. web_search_image_call: Text-to-image search call type, returned when the web_search_image tool is used. Contains a list of searched images. image_search_call: Image-to-image search call type, returned when the image_search tool is used. Contains a list of searched similar images. mcp_call: MCP call type, returned when the mcp tool is used. Contains the call results of the MCP service. file_search_call: Knowledge base search call type, returned when the file_search tool is used. Contains the retrieval queries and results from the knowledge base.

id*string

The unique identifier of the output item. All types of output items include this field.

role*string

Message role, fixed as assistant. Present only when type is message.

status*string

Output item status. Possible values: completed (completed), in_progress (in progress). Present when type is not reasoning.

name*string

The name of the tool or function. Present when type is function_call, web_search_image_call, image_search_call, or mcp_call. For web_search_image_call and image_search_call, the values are fixed as "web_search_image" and "image_search", respectively. For mcp_call, the value is the specific function name invoked in the MCP service (e.g., amap-maps-maps_geo).

arguments*string

Arguments for tool calls in JSON string format. Present when type is function_call, web_search_image_call, image_search_call, or mcp_call. Must be parsed using JSON.parse() before use. The arguments content for different tool types: web_search_image_call: {"queries": ["search keyword 1", "search keyword 2"]}, where queries is a list of search keywords automatically generated by the model based on user input. image_search_call: {"img_idx": 0, "bbox": [0, 0, 1000, 1000]}, where img_idx is the index of the input image (starting from 0), and bbox represents the bounding box coordinates [x1, y1, x2, y2] of the search area, with a coordinate range of 0-1000. function_call: The parameter object generated according to the user-defined function parameter schema. mcp_call: The parameter object for the invoked function in the MCP service.

call_id*string

The unique identifier for the function call. Present only when type is function_call. When returning function call results, this ID must be used to correlate the request with the response.

content*array<object>

Message content array. Present only when type is message.

[]?object
type*string

Content type, fixed as output_text.

text*string

Text content generated by the model.

annotations*string

Array of text annotations. Typically an empty array.

summary*array<string>

Array of reasoning summaries. Present only when type is reasoning. Each element contains a type field (value: summary_text) and a text field (summary text).

[]?string
action*object

Search action information. Present only when type is web_search_call.

query*string

Search query keywords.

type*string

Search type, fixed to search.

sources*string

List of search sources. Each element contains the type and url fields.

code*string

Code generated and executed by the model. Present only when type is code_interpreter_call.

outputs*array<string>

Array of code execution outputs. Only present when type is code_interpreter_call. Each element contains a type field (value: logs) and a logs field (code execution logs).

[]?string
container_id*string

Code interpreter container identifier. Present only when type is code_interpreter_call. Used to correlate multiple code executions within the same session.

goal*string

Extraction target description, specifying the information to be extracted from the webpage. Present only when type is web_extractor_call.

output*string

The output of the tool call, in string format. When the type is web_extractor_call, it is the summary of the extracted web content. When the type is web_search_image_call or image_search_call, it is a JSON string containing an array of image search results, where each element includes the title (image title), url (image URL), and index (sequence number) fields. When the type is mcp_call, it is the JSON string result returned by the MCP service.

urls*array<string>

List of extracted web page URLs. Only present when type is web_extractor_call.

[]?string
server_label*string

MCP service label. Present only when type is mcp_call. Identifies the MCP service used for this call.

queries*array<string>

The list of queries used for knowledge base retrieval. Present only when type is file_search_call. Array elements are strings representing search queries generated by the model.

[]?string
results*array<object>

Array of knowledge base retrieval results. Only present when type is file_search_call.

[]?object
file_id*string

File ID of the matched document.

filename*string

Match the document's filename.

score*number

Match relevance score, ranging from 0 to 1, where a higher value indicates greater relevance.

text*string

Matched document content snippet.

usage*object

Token consumption information for this request.

output_tokens*integer

Number of tokens output by the model.

input_tokens*integer

Number of input tokens.

total_tokens*integer

The total number of tokens consumed is the sum of input_tokens and output_tokens.

input_tokens_details*object

Fine-grained classification of output tokens when using the Qwen-VL model.

cached_tokens*integer

Number of cache-hit tokens.

output_tokens_details*object

Fine-grained classification of output tokens.

reasoning_tokens*integer

Thinking process token count.

x_details*object
input_tokens*integer

Number of input tokens.

output_tokens*integer

Number of tokens output by the model.

total_tokens*integer

The total number of tokens consumed is the sum of input_tokens and output_tokens.

x_billing_type*string

Fixed to response_api.

x_tools*object

Tool usage statistics. Includes the call count for each tool when built-in tools are used. Example: {"web_search": {"count": 1}}

error *object

The error object returned when the model fails to generate a response. null on success.

tools*array<string>

Echoes the complete content of the tools parameter in the request, with a structure identical to that of the tools parameter in the request body.

[]?string
tool_choice*string

Echoes the value of the tool_choice parameter in the request, with enumerated values of auto, none, and required.

curl -X POST "https://api.ygw.ai/api/v1/responses" \  -H "Authorization: string" \  -H "Content-Type: application/json" \  -d '{    "model": "string",    "input": "string"  }'
{
  "id": "string",
  "created_at": 0,
  "object": "string",
  "status": "string",
  "model": "string",
  "output": [
    {
      "type": "string",
      "id": "string",
      "role": "string",
      "status": "string",
      "name": "string",
      "arguments": "string",
      "call_id": "string",
      "content": [
        {
          "type": "string",
          "text": "string",
          "annotations": "string"
        }
      ],
      "summary": [
        "string"
      ],
      "action": {
        "query": "string",
        "type": "string",
        "sources": "string"
      },
      "code": "string",
      "outputs": [
        "string"
      ],
      "container_id": "string",
      "goal": "string",
      "output": "string",
      "urls": [
        "string"
      ],
      "server_label": "string",
      "queries": [
        "string"
      ],
      "results": [
        {
          "file_id": "string",
          "filename": "string",
          "score": 0,
          "text": "string"
        }
      ]
    }
  ],
  "usage": {
    "output_tokens": 0,
    "input_tokens": 0,
    "total_tokens": 0,
    "input_tokens_details": {
      "cached_tokens": 0
    },
    "output_tokens_details": {
      "reasoning_tokens": 0
    },
    "x_details": {
      "input_tokens": 0,
      "output_tokens": 0,
      "total_tokens": 0,
      "x_billing_type": "string"
    },
    "x_tools": {}
  },
  "error ": {},
  "tools": [
    "string"
  ],
  "tool_choice": "string"
}