Skip to content
Primary navigation

List run steps

Deprecated
client.beta.threads.runs.steps.list(stringrunID, StepListParams { thread_id, after, before, 3 more } params, RequestOptionsoptions?): CursorPage<RunStep { id, assistant_id, cancelled_at, 13 more } >
GET/threads/{thread_id}/runs/{run_id}/steps

Returns a list of run steps belonging to a run.

ParametersExpand Collapse
runID: string
params: StepListParams { thread_id, after, before, 3 more }
thread_id: string

Path param: The ID of the thread the run and run steps belong to.

after?: string

Query param: 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

Query param: 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, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.

include?: Array<RunStepInclude { } >

Query param: A list of additional fields to include in the response. Currently the only supported value is step_details.tool_calls[*].file_search.results[*].content to fetch the file search result content.

See the file search tool documentation for more information.

limit?: number

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

order?: "asc" | "desc"

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

One of the following:
"asc"
"desc"
ReturnsExpand Collapse
RunStep { id, assistant_id, cancelled_at, 13 more }

Represents a step in execution of a run.

id: string

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

assistant_id: string

The ID of the assistant associated with the run step.

cancelled_at: number | null

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

completed_at: number | null

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

created_at: number

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

expired_at: number | null

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

failed_at: number | null

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

last_error: LastError | null

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

code: "server_error" | "rate_limit_exceeded"

One of server_error or rate_limit_exceeded.

One of the following:
"server_error"
"rate_limit_exceeded"
message: string

A human-readable description of the error.

metadata: Metadata | null

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, and querying for objects via API or the dashboard.

Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.

object: "thread.run.step"

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

run_id: string

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

status: "in_progress" | "cancelled" | "failed" | 2 more

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

One of the following:
"in_progress"
"cancelled"
"failed"
"completed"
"expired"
step_details: MessageCreationStepDetails { message_creation, type } | ToolCallsStepDetails { tool_calls, type }

The details of the run step.

One of the following:
MessageCreationStepDetails { message_creation, type }

Details of the message creation by the run step.

message_creation: MessageCreation { message_id }
message_id: string

The ID of the message that was created by this run step.

type: "message_creation"

Always message_creation.

ToolCallsStepDetails { tool_calls, type }

Details of the tool call.

tool_calls: Array<ToolCall>

An array of tool calls the run step was involved in. These can be associated with one of three types of tools: code_interpreter, file_search, or function.

One of the following:
CodeInterpreterToolCall { id, code_interpreter, type }

Details of the Code Interpreter tool call the run step was involved in.

id: string

The ID of the tool call.

code_interpreter: CodeInterpreter { input, outputs }

The Code Interpreter tool call definition.

input: string

The input to the Code Interpreter tool call.

outputs: Array<Logs { logs, type } | Image { image, type } >

The outputs from the Code Interpreter tool call. Code Interpreter can output one or more items, including text (logs) or images (image). Each of these are represented by a different object type.

One of the following:
Logs { logs, type }

Text output from the Code Interpreter tool call as part of a run step.

logs: string

The text output from the Code Interpreter tool call.

type: "logs"

Always logs.

Image { image, type }
image: Image { file_id }
file_id: string

The file ID of the image.

type: "image"

Always image.

type: "code_interpreter"

The type of tool call. This is always going to be code_interpreter for this type of tool call.

FileSearchToolCall { id, file_search, type }
id: string

The ID of the tool call object.

One of the following:
type: "file_search"

The type of tool call. This is always going to be file_search for this type of tool call.

FunctionToolCall { id, function, type }
id: string

The ID of the tool call object.

function: Function { arguments, name, output }

The definition of the function that was called.

arguments: string

The arguments passed to the function.

name: string

The name of the function.

output: string | null

The output of the function. This will be null if the outputs have not been submitted yet.

type: "function"

The type of tool call. This is always going to be function for this type of tool call.

type: "tool_calls"

Always tool_calls.

thread_id: string

The ID of the thread that was run.

type: "message_creation" | "tool_calls"

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

One of the following:
"message_creation"
"tool_calls"
usage: Usage | null

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

completion_tokens: number

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

prompt_tokens: number

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

total_tokens: number

Total number of tokens used (prompt + completion).

List run steps

import OpenAI from "openai";
const openai = new OpenAI();

async function main() {
  const runStep = await openai.beta.threads.runs.steps.list(
    "run_abc123",
    { thread_id: "thread_abc123" }
  );
  console.log(runStep);
}

main();
{
  "object": "list",
  "data": [
    {
      "id": "step_abc123",
      "object": "thread.run.step",
      "created_at": 1699063291,
      "run_id": "run_abc123",
      "assistant_id": "asst_abc123",
      "thread_id": "thread_abc123",
      "type": "message_creation",
      "status": "completed",
      "cancelled_at": null,
      "completed_at": 1699063291,
      "expired_at": null,
      "failed_at": null,
      "last_error": null,
      "step_details": {
        "type": "message_creation",
        "message_creation": {
          "message_id": "msg_abc123"
        }
      },
      "usage": {
        "prompt_tokens": 123,
        "completion_tokens": 456,
        "total_tokens": 579
      }
    }
  ],
  "first_id": "step_abc123",
  "last_id": "step_abc456",
  "has_more": false
}
Returns Examples
{
  "object": "list",
  "data": [
    {
      "id": "step_abc123",
      "object": "thread.run.step",
      "created_at": 1699063291,
      "run_id": "run_abc123",
      "assistant_id": "asst_abc123",
      "thread_id": "thread_abc123",
      "type": "message_creation",
      "status": "completed",
      "cancelled_at": null,
      "completed_at": 1699063291,
      "expired_at": null,
      "failed_at": null,
      "last_error": null,
      "step_details": {
        "type": "message_creation",
        "message_creation": {
          "message_id": "msg_abc123"
        }
      },
      "usage": {
        "prompt_tokens": 123,
        "completion_tokens": 456,
        "total_tokens": 579
      }
    }
  ],
  "first_id": "step_abc123",
  "last_id": "step_abc456",
  "has_more": false
}