All Products
Search
Document Center

Alibaba Cloud Model Studio:Retrieve a response

Last Updated:May 15, 2026

Retrieve a completed model response by its Response ID.

China (Beijing)

The base_url for SDK calls is: https://dashscope.aliyuncs.com/compatible-mode/v1

HTTP request URL: GET https://dashscope.aliyuncs.com/compatible-mode/v1/responses/{response_id}

Path parameters

response_id string (required)

The Response ID to retrieve. The format is resp_xxx. You can get it from the response of the Create response API. Only Response IDs returned when store=true was set in the original creation request can be retrieved.

Python

import os
from openai import OpenAI

client = OpenAI(
    # If you have not configured an environment variable, replace the following line with: api_key="sk-xxx"
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
)

response = client.responses.retrieve("resp_xxx")
print(response)

Node.js

import OpenAI from "openai";

const openai = new OpenAI({
    // If you have not configured an environment variable, replace the following line with: apiKey: "sk-xxx"
    apiKey: process.env.DASHSCOPE_API_KEY,
    baseURL: "https://dashscope.aliyuncs.com/compatible-mode/v1"
});

async function main() {
    const response = await openai.responses.retrieve("resp_xxx");
    console.log(response);
}

main();

curl

curl https://dashscope.aliyuncs.com/compatible-mode/v1/responses/resp_xxx \
  -H "Authorization: Bearer $DASHSCOPE_API_KEY"

Response

Returns the same Response object as the Create response API. The fields are described below:

{
    "background": false,
    "completed_at": 1778676420,
    "created_at": 1778676418,
    "frequency_penalty": 0.0,
    "id": "resp_801bc2c4-93d9-910f-b35d-5274f5a737c1",
    "metadata": {},
    "model": "qwen-plus",
    "object": "response",
    "output": [
        {
            "content": [
                {
                    "annotations": [],
                    "text": "Hello! Nice to meet you. How can I help you?",
                    "type": "output_text"
                }
            ],
            "id": "msg_8c54756c-9b65-4a95-81d7-4276d91406db",
            "role": "assistant",
            "status": "completed",
            "type": "message"
        }
    ],
    "parallel_tool_calls": true,
    "presence_penalty": 0.0,
    "service_tier": "default",
    "status": "completed",
    "store": true,
    "temperature": 1.0,
    "tool_choice": "auto",
    "tools": [],
    "top_logprobs": 0,
    "top_p": 1.0,
    "usage": {
        "input_tokens": 45,
        "input_tokens_details": {
            "cached_tokens": 0
        },
        "output_tokens": 63,
        "output_tokens_details": {
            "reasoning_tokens": 0
        },
        "total_tokens": 108,
        "x_details": [
            {
                "input_tokens": 45,
                "output_tokens": 63,
                "prompt_tokens_details": {
                    "cached_tokens": 0
                },
                "total_tokens": 108,
                "x_billing_type": "response_api"
            }
        ]
    }
}

id string

The unique identifier for this response. The format is resp_xxx.

object string

The object type. Always response.

status string

The response status. Possible values: completed (completed), failed (failed), in_progress (in progress), cancelled (cancelled), queued (queued), incomplete (incomplete).

created_at integer

The Unix timestamp (in seconds) when the response was created.

completed_at integer

The Unix timestamp (in seconds) when the response finished generating. This field is null if the response is not complete.

error object

An error object returned when the model fails to generate a response. This field is null on success.

model string

The model ID used to generate the response.

output array

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

Array element properties

type string

The output item type. Possible values:

  • message: A message containing the model's final reply.

  • reasoning: Reasoning output. Returned when reasoning.effort is set to a value other than none or when thinking mode is enabled. Reasoning tokens are counted in output_tokens_details.reasoning_tokens and billed accordingly.

  • function_call: Function call output. Returned when using a custom function tool. You must handle the function call and return a result.

  • web_search_call: Web search call output. Returned when using the web_search tool.

  • code_interpreter_call: Code execution output. Returned when using the code_interpreter tool.

  • web_extractor_call: Web extraction output. Returned when using the web_extractor tool. Must be used together with the web_search tool.

  • web_search_image_call: Text-to-image search call output. Returned when using the web_search_image tool. Contains a list of images found.

  • image_search_call: Image-to-image search call output. Returned when using the image_search tool. Contains a list of similar images found.

  • mcp_call: MCP call output. Returned when using the mcp tool. Contains the result from the MCP service.

  • file_search_call: Knowledge base search call output. Returned when using the file_search tool. Contains retrieval queries and results from the knowledge base.

id string

The unique identifier for the output item. Present for all output types.

role string

The message role. Always assistant. Present only when type is message.

status string

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

name string

The tool or function name. 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 value is fixed as "web_search_image" and "image_search", respectively.

For mcp_call, the value is the specific function name called in the MCP service (for example, amap-maps-maps_geo).

arguments string

The tool call arguments, formatted as a JSON string. Present when type is function_call, web_search_image_call, image_search_call, or mcp_call. Parse it using JSON.parse() before use. The contents vary by tool type:

  • web_search_image_call: {"queries": ["search keyword 1", "search keyword 2"]}. The queries field contains 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]}. The img_idx field is the index of the input image (starting from 0). The bbox field contains the bounding box coordinates [x1, y1, x2, y2] of the search area, with values ranging from 0 to 1000.

  • function_call: An argument object generated according to the user-defined function parameter schema.

  • mcp_call: An argument object for the function called in the MCP service.

call_id string

The unique identifier for the function call. Present only when type is function_call. Use this ID to associate the request with the response when returning function call results.

content array

An array of message content. Present only when type is message.

Array element properties

type string

The content type. Always output_text.

text string

The text content generated by the model.

annotations array

An array of text annotations. Usually an empty array.

summary array

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

action object

Search action information. Present only when type is web_search_call.

Properties

query string

The search query keyword.

type string

The search type. Always search.

sources array

A list of search sources. Each element contains a type field and a url field.

code string

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

outputs array

An array of code execution outputs. Present only when type is code_interpreter_call. Each element contains a type field (value logs) and a logs field (code execution logs).

container_id string

The code interpreter container identifier. Present only when type is code_interpreter_call. Use it to associate multiple code executions within the same session.

goal string

A description of the extraction goal, specifying what information to extract from the webpage. Present only when type is web_extractor_call.

output string

The output result of the tool call, formatted as a string.

  • When type is web_extractor_call, this field contains a summary of the extracted webpage content.

  • When type is web_search_image_call or image_search_call, this field is a JSON string containing an array of image search results. Each result includes a title (image title), url (image URL), and index (ordinal number) field.

  • When type is mcp_call, this field is a JSON string result returned by the MCP service.

urls array

A list of URLs of the webpages extracted. Present only when type is web_extractor_call.

server_label string

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

queries array

A list of queries used for knowledge base retrieval. Present only when type is file_search_call. Each array element is a string representing a search query generated by the model.

results array

An array of knowledge base retrieval results. Present only when type is file_search_call.

Array element properties

file_id string

The file ID of the matched document.

filename string

The filename of the matched document.

score float

The relevance score, ranging from 0 to 1. A higher value indicates greater relevance.

text string

A snippet of the matched document content.

usage object

Token usage information for this request.

Properties

input_tokens integer

The number of input tokens.

output_tokens integer

The number of output tokens generated by the model.

total_tokens integer

The total number of tokens used, equal to the sum of input_tokens and output_tokens.

input_tokens_details object

Fine-grained classification of input tokens.

Properties

cached_tokens integer

The number of tokens that hit the cache.

output_tokens_details object

Fine-grained classification of output tokens.

Properties

reasoning_tokens integer

The number of reasoning tokens.

x_details array

Billing details.

Properties

input_tokens integer

The number of input tokens for this billing type.

output_tokens integer

The number of output tokens for this billing type.

total_tokens integer

The total number of tokens for this billing type.

x_billing_type string

Always response_api.

prompt_tokens_details object

Returned when Session caching is enabled. Contains a cached_tokens field (number of tokens that hit the cache).

x_tools object

Tool usage statistics. When built-in tools are used, this field contains the call count for each tool. Example: {"web_search": {"count": 1}}

tools array

Echoes the full content of the tools parameter from the original Create response request. The structure matches the tools parameter in the request body. An empty array [] if no tools were used.

tool_choice string

Echoes the value of the tool_choice parameter from the original Create response request. Possible values: auto, none, required.

parallel_tool_calls boolean

Echoes the value of the parallel_tool_calls parameter from the original Create response request. Indicates whether the model is allowed to call multiple tools in parallel.

temperature float

Echoes the value of the temperature parameter from the original Create response request. The sampling temperature controls the diversity of the model's output. Valid range: [0, 2). Returns the model's default value if not set.

top_p float

Echoes the value of the top_p parameter from the original Create response request. The nucleus sampling probability threshold. Valid range: (0, 1.0]. Returns the model's default value if not set.

frequency_penalty float

Echoes the value of the frequency_penalty parameter from the original Create response request. The frequency penalty coefficient. Positive values reduce the likelihood of repeated words.

presence_penalty float

Echoes the value of the presence_penalty parameter from the original Create response request. The presence penalty coefficient. Positive values increase the likelihood of introducing new topics.

top_logprobs integer

Echoes the value of the top_logprobs parameter from the original Create response request. The number of most likely tokens returned at each position. Returns 0 if not enabled.

store boolean

Echoes the value of the store parameter from the original Create response request. true means the response is stored and can be referenced by previous_response_id. false means the response is not stored.

service_tier string

The service tier. Always default.

background boolean

Indicates whether the response was executed asynchronously in the background. Model Studio currently supports only synchronous calls, so this field is always false.

metadata object

Echoes the content of the metadata parameter from the original Create response request. An object for attaching custom key-value pairs. An empty object {} if not set.

Error response

If the specified Response ID does not exist, the following error is returned:

{
    "error": {
        "message": "Response with id 'resp_xxx' not found.",
        "type": "InvalidParameter"
    }
}