This API provides capabilities for scenario-based conversations, research, and writing. It uses the agent_id and agent_version parameters from Agent Application Management.
Request syntax
Request parameters
Parameter name | Type | Required | Description |
|---|---|---|---|
stream | bool | Yes | Set this parameter to true. The current version only supports streaming output. If you set this parameter to |
input | object | Yes | The input field. |
input.request_id | str | No | The request ID. This is a custom ID defined by your service. |
input.messages | array[object] | Yes | The conversation messages. |
input.messages.[].role | str | Yes | The role. The enumeration values are |
input.messages.[].content | str | Yes | The content to generate. |
parameters | object | Yes | The configuration parameter field. |
parameters.agent_options | object | Yes | Parameters specific to the agent. |
parameters.agent_options.agent_id | string | Yes | The application ID. |
parameters.agent_options.agent_version | string | Yes | The application version. |
parameters.agent_options.session_files | array[string] | No | A list of dynamic file IDs. For more information about how to obtain a file ID, see the file upload document. You can pass a maximum of 10 file IDs. |
Response parameters
Parameter | Type | Required | Description |
|---|---|---|---|
request_id | str | Yes | The request ID from the DashScope platform. |
code | str | Yes | The status code. A value of 200 indicates success. |
message | str | Yes | The status message. |
output | object | Yes | The output field. |
output.request_id | str | No | User-defined Request ID |
output.choices | array[object] | Yes | The model output information. |
output.choices.[].finish_reason | str | Yes | The reason why the generation ended. Only the last package outputs |
output.choices.[].message | object | Yes | The conversation message. |
output.choices.[].message.role | str | Yes | The role. The enumeration values are |
output.choices.[].message.content | str | array[object] | Yes | The generated content or the content returned by the tool. When report generation is enabled in the configuration, the report message body is of the |
output.choices.[].message.reasoning_content | str | No | The thinking content. If the `content` field is empty, the system attempts to retrieve the `reasoning_content` from the last round of deep thinking. |
output.choices.[].message.tool_calls | array[object] | No | Information about the tool call. |
output.choices.[].message.tool_calls[0].arguments | dcit[str,object] | No | The parameters for the tool call. |
output.choices.[].message.tool_calls[0].name | str | No | The name of the tool that was called. |
output.choices.[].message.additional_kwargs.extra_json | Any | No | When a tool call returns, this field carries the structured output information. |
output.choices.[].message.extra | dict | No | The step status information. |
output.choices.[].message.extra.group | str | No | The execution phase. |
output.choices.[].message.extra.step_change | str | No | The step change event. |
output.choices.[].message.extra.step | str | No | The current step. |
output.choices.[].message.response_metadata | dict | No | Detailed information about the request model call. |
output.usage | object | No | Usage statistics. |
output.usage.input_tokens | int | No | Input tokens. |
output.usage.output_tokens | int | No | Output tokens. |
output.usage.total_tokens | int | No | Total tokens. |
Plan enumerations
Execution phase ( | Description | Notes |
|---|---|---|
planning | Planning | Corresponds to the plan model. The system is in the task planning phase. This phase includes `start` and `end` events. |
generating | Generating | Represents the writing model. The system is in the report generation phase. This phase does not distinguish detailed event changes and has no `start` or `end` events. The `step` status only includes `thinking` and `generating`, and no tools are called. |
Current step ( | Description and notes |
|---|---|
planning | Planning |
thinking | Thinking |
reporting | Summarizing (specific to legal scenarios) |
generating | Generating |
tool_calling | Calling a tool |
tool_calling_{tool_name} | Calling a tool. The tool name is included. |
- For model-related reasons, the
step_changevalue might not exist. Therefore, use the persistentstepflag whenever possible. - For an empty package, the
step,step_change, andgroupfields might not exist. plan,think, andgenerationare each composed of anxxx_startevent and anxxx_endevent.tool_callis composed of three events:tool_call_start,tool_calling, andtool_return.tool_call_startindicates the start of the tool call. The system begins to collect tool call information in a stream. At this point, details such asnameandargumentsare not available for output.tool_callingindicates that the complete parameters for the tool call have been retrieved and are being output.tool_returnindicates that the tool call has completed and includes the structured information from the tool's return value.
Step change event ( | Value of | Event name | Explanation |
|---|---|---|---|
plan_start |
| Start planning | The |
plan_end |
| End planning | The |
think_start |
| Start thinking | Same as the |
think_end |
| End thinking | Same as the |
report_start |
| Start summarizing | Same as the |
report_end |
| End summarizing | Same as the |
generation_start |
| Start generating | Same as the |
generation_end |
| End generating | Same as the |
tool_call_start |
| Start tool call | Indicates that the tool call has started. The system begins to collect tool call information in a stream. At this point, details such as `name` and `arguments` cannot be output. |
tool_calling |
| Tool call in progress | The specific parameters and name of the tool call are output. The |
tool_return |
| Tool return | Includes the tool return information. The |
Examples
Request example
Response example
type field in content:
file_path: The file storage path. You can use this path for subsequent PDF exports and to retrieve the file download links.md_file_url: The MD file download link.html_file_url: The HTML file download link.