Skip to main content
Assistant API (Deprecated)

Run steps (Deprecated)

Run steps describe the actions that an agent takes during a run, including model and tool calls.

The Assistant API is being deprecated. Migrate to the Responses API as an alternative. The Responses API includes multiple built-in tools and supports multi-turn context management.

List run steps

Returns a list of all steps for a run task.

Sample request

  • HTTP
  • SDK
curl --location 'https://dashscope-intl.aliyuncs.com/api/v1/threads/thread_cc2a3e9d-436b-482b-91c5-377e0f376506/runs/run_3de634fa-75d4-4370-adcf-92ba2a60c396/steps?limit=20&order=asc' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"

Request body

Parameter Name

Type

Required

Default

Description

run_id

string

Yes

The ID of the Run for which you want to list the steps.

thread_id

string

Yes

The ID of the Thread.

limit

integer

No

None

The number of running steps to retrieve. The default is None. A value of None uses the server-side default value.

order

string

No

None

The order in which to sort the results based on the created_at field. You can set this parameter to asc (ascending) or desc (descending). The default value is None, which indicates that the server-side default sorting method is used.

after

string

No

None

ID of the run step to use as a cursor for pagination. When provided, returns the page of results immediately after this step.

before

string

No

None

ID of the run step to use as a cursor for pagination. When provided, returns the page of results immediately before this step.

workspace

string

Yes

None

The Workspace ID for Alibaba Cloud Model Studio is required only if the `api_key` is an API key for a sub-workspace.

api_key

string

Yes

None

The API Key of Model Studio. We recommend that you configure the API Key as an environment variable.

Sample response

{
    "object": "list",
    "data": [
        {
            "id": "[REDACTED]",
            "object": "thread.run.step",
            "created_at": 1711517599333,
            "assistant_id": "[REDACTED]",
            "thread_id": "[REDACTED]",
            "run_id": "[REDACTED]",
            "type": "message_creation",
            "status": "completed",
            "step_details": {
                "type": "message_creation",
                "message_creation": {
                    "message_id": "[REDACTED]"
                }
            },
            "last_error": {
                "code": "",
                "message": ""
            },
            "expired_at": 0,
            "cancelled_at": -1,
            "failed_at": -1,
            "completed_at": -1,
            "metadata": {},
            "usage": {}
        }
    ],
    "first_id": "[REDACTED]",
    "last_id": "[REDACTED]",
    "has_more": false,
    "request_id": "[REDACTED]"
}

Response body

A list of run step objects

Retrieve a run step

Sample request

  • HTTP
  • SDK
Sample code
curl --location 'https://dashscope-intl.aliyuncs.com/api/v1/threads/thread_cc2a3e9d-436b-482b-91c5-377e0f376506/runs/run_3de634fa-75d4-4370-adcf-92ba2a60c396/steps/step_4db180b5-d44a-4b12-9390-4307c6cb87a5' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"

Request body

Parameter name

Type

Required

Default

Description

step_id

string

Yes

The ID of the RunStep to retrieve.

thread_id

string

Yes

The ID of the Thread.

run_id

string

Yes

The ID of the Run.

workspace

string

Yes

None

The Workspace ID for Alibaba Cloud Model Studio is required only if you are using a sub-workspace API Key.

api_key

string

Yes

None

The API Key of Model Studio. We recommend that you configure the API Key as an environment variable.

Sample response

{
    "assistant_id": "[REDACTED]",
    "cancelled_at": null,
    "completed_at": 1735025124000,
    "created_at": 1735025123150,
    "expired_at": null,
    "failed_at": null,
    "id": "[REDACTED]",
    "last_error": null,
    "metadata": {},
    "object": "thread.run.step",
    "request_id": "[REDACTED]",
    "run_id": "[REDACTED]",
    "status": "completed",
    "step_details": {
        "message_creation": {
            "message_id": "[REDACTED]"
        },
        "type": "message_creation"
    },
    "thread_id": "[REDACTED]",
    "type": "message_creation",
    "usage": null
}

Response body

The run step object that matches the specified ID.

Run step object

Represents a step in the execution process of a run.

Object example

{
  "id": "[REDACTED]",
  "assistant_id": "[REDACTED]",
  "cancelled_at": null,
  "completed_at": 1678886400,
  "created_at": 1678886300,
  "expired_at": null,
  "failed_at": null,
  "last_error": null,
  "metadata": {
    "user_id": "[REDACTED]",
    "context": "order_processing"
  },
  "object": "thread.run.step",
  "run_id": "[REDACTED]",
  "status": "completed",
  "step_details": {
    "type": "message_creation",
    "message_creation": {
      "message_id": "[REDACTED]"
    }
  },
  "thread_id": "[REDACTED]",
  "type": "message_creation",
  "usage": {
    "prompt_tokens": 10,
    "completion_tokens": 20,
    "total_tokens": 30
  }
}

Object attributes

Parameter Name

Type

Description

id

string

The unique identifier of the run step, which can be referenced in API endpoints.

assistant_id

string

The ID of the assistant associated with this run step.

cancelled_at

integer

The 13-digit UNIX timestamp (in milliseconds) when the run step was canceled.

completed_at

integer

The 13-digit UNIX timestamp (in milliseconds) when the run step was completed.

created_at

integer

The 13-digit UNIX timestamp (in milliseconds) when the run step was created.

expired_at

integer

The 13-digit UNIX timestamp (in milliseconds) when the run step expired. If the parent run has expired, the step is also considered expired.

failed_at

integer

The 13-digit UNIX timestamp (in milliseconds) when the run step failed.

last_error

object

The last error associated with this run step. This parameter is null if no error occurred.

metadata

map

A set of up to 16 key-value pairs that can be attached to the object. This is used to store additional information about the object in a structured format. The maximum length of a key is 64 characters and the maximum length of a value is 512 characters.

object

string

The object type, which is always thread.run.step.

run_id

string

The ID of the run to which this run step belongs.

status

string

The status of the run step. Valid values: in_progress, cancelled, failed, completed, or expired.

step_details

object

The details of the run step.

thread_id

string

The ID of the running thread.

type

string

The type of the run step. Valid values: message_creation or tool_calls.

usage

object

Resource usage statistics.

status_code

integer

The HTTP status code. Note: This parameter is used for internal processing. In most cases, you do not need to concern yourself with this parameter.

Error codes

If a call fails and returned an error message, see Error codes for troubleshooting.