Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Openai Openai node Beta Threads Steps

From Leeroopedia
Knowledge Sources
Domains SDK, Assistants, Threads, Beta
Last Updated 2026-02-15 12:00 GMT

Overview

The Beta Threads Run Steps resource class provides deprecated methods to retrieve and list individual steps within an assistant run, along with comprehensive types for tool call details and step deltas.

Description

The Steps class extends APIResource and is marked @deprecated in favor of the Responses API. It provides two methods -- retrieve and list -- that map to the /threads/{thread_id}/runs/{run_id}/steps REST endpoints. Each method automatically injects the OpenAI-Beta: assistants=v2 header. The retrieve method accepts an optional include parameter to fetch file search result content.

The RunStep interface represents a step in the execution of a run. Steps have a type of either message_creation or tool_calls, a status (in_progress, cancelled, failed, completed, expired), and detailed step_details which is a union of MessageCreationStepDetails and ToolCallsStepDetails. Each step tracks timestamps for creation, completion, failure, cancellation, and expiration, along with usage statistics and last_error information.

The file defines extensive tool call types: CodeInterpreterToolCall (with input code and outputs as logs or images), FileSearchToolCall (with ranking options and search results), and FunctionToolCall (with function name, arguments, and output). Corresponding delta types (CodeInterpreterToolCallDelta, FileSearchToolCallDelta, FunctionToolCallDelta) support streaming. The RunStepDeltaEvent and RunStepDelta interfaces model changes to run steps during streaming.

Usage

Use this resource to inspect the individual steps of an assistant run. Access it via client.beta.threads.runs.steps. Steps provide visibility into what actions the assistant took during a run, including tool calls and message creation. This API is deprecated in favor of the Responses API.

Code Reference

Source Location

Signature

/** @deprecated The Assistants API is deprecated in favor of the Responses API */
export class Steps extends APIResource {
  retrieve(
    stepID: string,
    params: StepRetrieveParams,
    options?: RequestOptions,
  ): APIPromise<RunStep>;

  list(
    runID: string,
    params: StepListParams,
    options?: RequestOptions,
  ): PagePromise<RunStepsPage, RunStep>;
}

export interface RunStep {
  id: string;
  assistant_id: string;
  cancelled_at: number | null;
  completed_at: number | null;
  created_at: number;
  expired_at: number | null;
  failed_at: number | null;
  last_error: RunStep.LastError | null;
  metadata: Shared.Metadata | null;
  object: 'thread.run.step';
  run_id: string;
  status: 'in_progress' | 'cancelled' | 'failed' | 'completed' | 'expired';
  step_details: MessageCreationStepDetails | ToolCallsStepDetails;
  thread_id: string;
  type: 'message_creation' | 'tool_calls';
  usage: RunStep.Usage | null;
}

Import

import OpenAI from 'openai';
// Access via client.beta.threads.runs.steps

I/O Contract

Inputs

Name Type Required Description
stepID string Yes (retrieve) The run step identifier to retrieve
runID string Yes (list) The run identifier whose steps to list
thread_id string Yes The thread ID that the run and step belong to
run_id string Yes (retrieve) The run ID that the step belongs to
include Array<RunStepInclude> No Additional fields to include (e.g., file search result content)
before string No (list) Cursor for pagination
order 'desc' No (list) Sort order by created_at timestamp
limit number No (list) Number of items per page
after string No (list) Cursor for forward pagination

Outputs

Name Type Description
RunStep RunStep A step in run execution with id, type, status, step_details, usage, and timestamps
RunStepsPage CursorPage<RunStep> Paginated list of run step objects
ToolCall FileSearchToolCall | FunctionToolCall Union of tool call detail types
RunStepDeltaEvent RunStepDeltaEvent Streaming delta event for run step changes

Usage Examples

Basic Usage

import OpenAI from 'openai';

const client = new OpenAI();

// List all steps for a run
const steps = await client.beta.threads.runs.steps.list('run_abc123', {
  thread_id: 'thread_abc123',
  order: 'asc',
});

for await (const step of steps) {
  console.log(step.type, step.status);

  if (step.type === 'tool_calls') {
    const details = step.step_details;
    if (details.type === 'tool_calls') {
      for (const toolCall of details.tool_calls) {
        console.log(toolCall.type, toolCall.id);
      }
    }
  }
}

// Retrieve a specific step with file search content
const step = await client.beta.threads.runs.steps.retrieve('step_abc123', {
  thread_id: 'thread_abc123',
  run_id: 'run_abc123',
  include: ['step_details.tool_calls[*].file_search.results[*].content'],
});

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment