List run steps

GET /threads/{thread_id}/runs/{run_id}/steps

Returns a list of run steps belonging to a run.

Path parameters

  • thread_id string Required

    The ID of the thread the run and run steps belong to.

  • run_id string Required

    The ID of the run the run steps belong to.

Query parameters

  • limit integer

    A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.

    Default value is 20.

  • order string

    Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.

    Values are asc or desc. Default value is desc.

  • after string

    A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.

  • before string

    A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.

Responses

  • 200 application/json

    OK

    Hide response attributes Show response attributes object
    • object string Required
    • data array[object] Required

      Represents a step in execution of a run.

      Hide data attributes Show data attributes object
      • id string Required

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

      • object string Required

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

        Value is thread.run.step.

      • created_at integer Required

        The Unix timestamp (in seconds) for when the run step was created.

      • assistant_id string Required

        The ID of the assistant associated with the run step.

      • thread_id string Required

        The ID of the thread that was run.

      • run_id string Required

        The ID of the run that this run step is a part of.

      • type string Required

        The type of run step, which can be either message_creation or tool_calls.

        Values are message_creation or tool_calls.

      • status string Required

        The status of the run step, which can be either in_progress, cancelled, failed, completed, or expired.

        Values are in_progress, cancelled, failed, completed, or expired.

      • step_details object Required

        One of:
      • last_error object | null Required

        The last error associated with this run step. Will be null if there are no errors.

        Hide last_error attributes Show last_error attributes object | null
        • code string Required

          One of server_error or rate_limit_exceeded.

          Values are server_error or rate_limit_exceeded.

        • message string Required

          A human-readable description of the error.

      • expired_at integer | null Required

        The Unix timestamp (in seconds) for when the run step expired. A step is considered expired if the parent run is expired.

      • cancelled_at integer | null Required

        The Unix timestamp (in seconds) for when the run step was cancelled.

      • failed_at integer | null Required

        The Unix timestamp (in seconds) for when the run step failed.

      • completed_at integer | null Required

        The Unix timestamp (in seconds) for when the run step completed.

      • metadata object | null Required

        Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long.

      • usage object | null Required

        Usage statistics related to the run step. This value will be null while the run step's status is in_progress.

        Hide usage attributes Show usage attributes object | null
        • completion_tokens integer Required

          Number of completion tokens used over the course of the run step.

        • prompt_tokens integer Required

          Number of prompt tokens used over the course of the run step.

        • total_tokens integer Required

          Total number of tokens used (prompt + completion).

    • first_id string Required
    • last_id string Required
    • has_more boolean Required
GET /threads/{thread_id}/runs/{run_id}/steps
curl \
 -X GET https://api.openai.com/v1/threads/{thread_id}/runs/{run_id}/steps \
 -H "Authorization: Bearer $ACCESS_TOKEN"
Response examples (200)
{
  "object": "list",
  "data": [
    {
      "id": "string",
      "object": "thread.run.step",
      "created_at": 42,
      "assistant_id": "string",
      "thread_id": "string",
      "run_id": "string",
      "type": "message_creation",
      "status": "in_progress",
      "step_details": {
        "type": "message_creation",
        "message_creation": {
          "message_id": "string"
        }
      },
      "last_error": {
        "code": "server_error",
        "message": "string"
      },
      "expired_at": 42,
      "cancelled_at": 42,
      "failed_at": 42,
      "completed_at": 42,
      "metadata": {},
      "usage": {
        "completion_tokens": 42,
        "prompt_tokens": 42,
        "total_tokens": 42
      }
    }
  ],
  "first_id": "step_abc123",
  "last_id": "step_abc456",
  "has_more": false
}