Class: OpenAI::Resources::Beta::Threads::Runs Deprecated

Inherits:
Object
  • Object
show all
Defined in:
lib/openai/resources/beta/threads/runs.rb,
lib/openai/resources/beta/threads/runs/steps.rb

Overview

Deprecated.

The Assistants API is deprecated in favor of the Responses API

Build Assistants that can call models and use tools.

Defined Under Namespace

Classes: Steps

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Runs

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Runs.

Parameters:

API:

  • private



389
390
391
392
# File 'lib/openai/resources/beta/threads/runs.rb', line 389

def initialize(client:)
  @client = client
  @steps = OpenAI::Resources::Beta::Threads::Runs::Steps.new(client: client)
end

Instance Attribute Details

#stepsOpenAI::Resources::Beta::Threads::Runs::Steps (readonly)

Build Assistants that can call models and use tools.

Returns:



13
14
15
# File 'lib/openai/resources/beta/threads/runs.rb', line 13

def steps
  @steps
end

Instance Method Details

#cancel(run_id, thread_id:, request_options: {}) ⇒ OpenAI::Models::Beta::Threads::Run

Deprecated.

The Assistants API is deprecated in favor of the Responses API

Cancels a run that is in_progress.

Parameters:

  • The ID of the run to cancel.

  • The ID of the thread to which this run belongs.

Returns:

See Also:



279
280
281
282
283
284
285
286
287
288
289
290
291
# File 'lib/openai/resources/beta/threads/runs.rb', line 279

def cancel(run_id, params)
  parsed, options = OpenAI::Beta::Threads::RunCancelParams.dump_request(params)
  thread_id =
    parsed.delete(:thread_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :post,
    path: ["threads/%1$s/runs/%2$s/cancel", thread_id, run_id],
    model: OpenAI::Beta::Threads::Run,
    options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  )
end

#create(thread_id, assistant_id:, include: nil, additional_instructions: nil, additional_messages: nil, instructions: nil, max_completion_tokens: nil, max_prompt_tokens: nil, metadata: nil, model: nil, parallel_tool_calls: nil, reasoning_effort: nil, response_format: nil, temperature: nil, tool_choice: nil, tools: nil, top_p: nil, truncation_strategy: nil, request_options: {}) ⇒ OpenAI::Models::Beta::Threads::Run

Deprecated.

The Assistants API is deprecated in favor of the Responses API

See #create_stream_raw for streaming counterpart.

Some parameter documentations has been truncated, see Models::Beta::Threads::RunCreateParams for more details.

Create a run.

Parameters:

  • Path param: The ID of the thread to run.

  • Body param: The ID of the [assistant](platform.openai.com/docs/api-refer

  • Query param: A list of additional fields to include in the response. Currently t

  • Body param: Appends additional instructions at the end of the instructions for t

  • Body param: Adds additional messages to the thread before creating the run.

  • Body param: Overrides the [instructions](platform.openai.com/docs/api-re

  • Body param: The maximum number of completion tokens that may be used over the co

  • Body param: The maximum number of prompt tokens that may be used over the course

  • Body param: Set of 16 key-value pairs that can be attached to an object. This ca

  • Body param: The ID of the [Model](platform.openai.com/docs/api-reference

  • Body param: Whether to enable [parallel function calling](platform.opena

  • Body param: Constrains effort on reasoning for

  • Body param: Specifies the format that the model must output. Compatible with [GP

  • Body param: What sampling temperature to use, between 0 and 2. Higher values lik

  • Body param: Controls which (if any) tool is called by the model.

  • Body param: Override the tools the assistant can use for this run. This is usefu

  • Body param: An alternative to sampling with temperature, called nucleus sampling

  • Body param: Controls for how a thread will be truncated prior to the run. Use th

Returns:

See Also:



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/openai/resources/beta/threads/runs.rb', line 68

def create(thread_id, params)
  query_params = [:include]
  parsed, options = OpenAI::Beta::Threads::RunCreateParams.dump_request(params)
  query = OpenAI::Internal::Util.encode_query_params(parsed.slice(*query_params))
  if parsed[:stream]
    message = "Please use `#create_stream_raw` for the streaming use case."
    raise ArgumentError.new(message)
  end
  @client.request(
    method: :post,
    path: ["threads/%1$s/runs", thread_id],
    query: query,
    body: parsed.except(*query_params),
    model: OpenAI::Beta::Threads::Run,
    options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  )
end

#create_stream_raw(thread_id, assistant_id:, include: nil, additional_instructions: nil, additional_messages: nil, instructions: nil, max_completion_tokens: nil, max_prompt_tokens: nil, metadata: nil, model: nil, parallel_tool_calls: nil, reasoning_effort: nil, response_format: nil, temperature: nil, tool_choice: nil, tools: nil, top_p: nil, truncation_strategy: nil, request_options: {}) ⇒ OpenAI::Internal::Stream<OpenAI::Models::Beta::AssistantStreamEvent::ThreadCreated, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCreated, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunQueued, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunInProgress, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunRequiresAction, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCompleted, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunIncomplete, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunFailed, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCancelling, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCancelled, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunExpired, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepCreated, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepInProgress, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepDelta, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepCompleted, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepFailed, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepCancelled, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepExpired, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageCreated, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageInProgress, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageDelta, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageCompleted, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageIncomplete, OpenAI::Models::Beta::AssistantStreamEvent::ErrorEvent>

Deprecated.

The Assistants API is deprecated in favor of the Responses API

See #create for non-streaming counterpart.

Some parameter documentations has been truncated, see Models::Beta::Threads::RunCreateParams for more details.

Create a run.

Parameters:

  • Path param: The ID of the thread to run.

  • Body param: The ID of the [assistant](platform.openai.com/docs/api-refer

  • Query param: A list of additional fields to include in the response. Currently t

  • Body param: Appends additional instructions at the end of the instructions for t

  • Body param: Adds additional messages to the thread before creating the run.

  • Body param: Overrides the [instructions](platform.openai.com/docs/api-re

  • Body param: The maximum number of completion tokens that may be used over the co

  • Body param: The maximum number of prompt tokens that may be used over the course

  • Body param: Set of 16 key-value pairs that can be attached to an object. This ca

  • Body param: The ID of the [Model](platform.openai.com/docs/api-reference

  • Body param: Whether to enable [parallel function calling](platform.opena

  • Body param: Constrains effort on reasoning for

  • Body param: Specifies the format that the model must output. Compatible with [GP

  • Body param: What sampling temperature to use, between 0 and 2. Higher values lik

  • Body param: Controls which (if any) tool is called by the model.

  • Body param: Override the tools the assistant can use for this run. This is usefu

  • Body param: An alternative to sampling with temperature, called nucleus sampling

  • Body param: Controls for how a thread will be truncated prior to the run. Use th

Returns:

See Also:



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/openai/resources/beta/threads/runs.rb', line 139

def create_stream_raw(thread_id, params)
  query_params = [:include]
  parsed, options = OpenAI::Beta::Threads::RunCreateParams.dump_request(params)
  query = OpenAI::Internal::Util.encode_query_params(parsed.slice(*query_params))
  unless parsed.fetch(:stream, true)
    message = "Please use `#create` for the non-streaming use case."
    raise ArgumentError.new(message)
  end
  parsed.store(:stream, true)
  @client.request(
    method: :post,
    path: ["threads/%1$s/runs", thread_id],
    query: query,
    headers: {"accept" => "text/event-stream"},
    body: parsed.except(*query_params),
    stream: OpenAI::Internal::Stream,
    model: OpenAI::Beta::AssistantStreamEvent,
    options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  )
end

#list(thread_id, after: nil, before: nil, limit: nil, order: nil, request_options: {}) ⇒ OpenAI::Internal::CursorPage<OpenAI::Models::Beta::Threads::Run>

Deprecated.

The Assistants API is deprecated in favor of the Responses API

Some parameter documentations has been truncated, see Models::Beta::Threads::RunListParams for more details.

Returns a list of runs belonging to a thread.

Parameters:

  • The ID of the thread the run belongs to.

  • A cursor for use in pagination. after is an object ID that defines your place

  • A cursor for use in pagination. before is an object ID that defines your place

  • A limit on the number of objects to be returned. Limit can range between 1 and 1

  • Sort order by the created_at timestamp of the objects. asc for ascending ord

Returns:

See Also:



251
252
253
254
255
256
257
258
259
260
261
262
# File 'lib/openai/resources/beta/threads/runs.rb', line 251

def list(thread_id, params = {})
  parsed, options = OpenAI::Beta::Threads::RunListParams.dump_request(params)
  query = OpenAI::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["threads/%1$s/runs", thread_id],
    query: query,
    page: OpenAI::Internal::CursorPage,
    model: OpenAI::Beta::Threads::Run,
    options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  )
end

#retrieve(run_id, thread_id:, request_options: {}) ⇒ OpenAI::Models::Beta::Threads::Run

Deprecated.

The Assistants API is deprecated in favor of the Responses API

Some parameter documentations has been truncated, see Models::Beta::Threads::RunRetrieveParams for more details.

Retrieves a run.

Parameters:

Returns:

See Also:



178
179
180
181
182
183
184
185
186
187
188
189
190
# File 'lib/openai/resources/beta/threads/runs.rb', line 178

def retrieve(run_id, params)
  parsed, options = OpenAI::Beta::Threads::RunRetrieveParams.dump_request(params)
  thread_id =
    parsed.delete(:thread_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["threads/%1$s/runs/%2$s", thread_id, run_id],
    model: OpenAI::Beta::Threads::Run,
    options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  )
end

#submit_tool_outputs(run_id, thread_id:, tool_outputs:, request_options: {}) ⇒ OpenAI::Models::Beta::Threads::Run

Deprecated.

The Assistants API is deprecated in favor of the Responses API

See #submit_tool_outputs_stream_raw for streaming counterpart.

Some parameter documentations has been truncated, see Models::Beta::Threads::RunSubmitToolOutputsParams for more details.

When a run has the ‘status: “requires_action”` and required_action.type is submit_tool_outputs, this endpoint can be used to submit the outputs from the tool calls once they’re all completed. All outputs must be submitted in a single request.

Parameters:

  • Path param: The ID of the run that requires the tool output submission.

  • Path param: The ID of the [thread](platform.openai.com/docs/api-referenc

  • Body param: A list of tools for which the outputs are being submitted.

Returns:

See Also:



319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
# File 'lib/openai/resources/beta/threads/runs.rb', line 319

def submit_tool_outputs(run_id, params)
  parsed, options = OpenAI::Beta::Threads::RunSubmitToolOutputsParams.dump_request(params)
  if parsed[:stream]
    message = "Please use `#submit_tool_outputs_stream_raw` for the streaming use case."
    raise ArgumentError.new(message)
  end
  thread_id =
    parsed.delete(:thread_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :post,
    path: ["threads/%1$s/runs/%2$s/submit_tool_outputs", thread_id, run_id],
    body: parsed,
    model: OpenAI::Beta::Threads::Run,
    options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  )
end

#submit_tool_outputs_stream_raw(run_id, thread_id:, tool_outputs:, request_options: {}) ⇒ OpenAI::Internal::Stream<OpenAI::Models::Beta::AssistantStreamEvent::ThreadCreated, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCreated, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunQueued, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunInProgress, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunRequiresAction, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCompleted, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunIncomplete, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunFailed, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCancelling, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCancelled, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunExpired, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepCreated, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepInProgress, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepDelta, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepCompleted, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepFailed, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepCancelled, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepExpired, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageCreated, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageInProgress, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageDelta, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageCompleted, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageIncomplete, OpenAI::Models::Beta::AssistantStreamEvent::ErrorEvent>

Deprecated.

The Assistants API is deprecated in favor of the Responses API

See #submit_tool_outputs for non-streaming counterpart.

Some parameter documentations has been truncated, see Models::Beta::Threads::RunSubmitToolOutputsParams for more details.

When a run has the ‘status: “requires_action”` and required_action.type is submit_tool_outputs, this endpoint can be used to submit the outputs from the tool calls once they’re all completed. All outputs must be submitted in a single request.

Parameters:

  • Path param: The ID of the run that requires the tool output submission.

  • Path param: The ID of the [thread](platform.openai.com/docs/api-referenc

  • Body param: A list of tools for which the outputs are being submitted.

Returns:

See Also:



364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
# File 'lib/openai/resources/beta/threads/runs.rb', line 364

def submit_tool_outputs_stream_raw(run_id, params)
  parsed, options = OpenAI::Beta::Threads::RunSubmitToolOutputsParams.dump_request(params)
  unless parsed.fetch(:stream, true)
    message = "Please use `#submit_tool_outputs` for the non-streaming use case."
    raise ArgumentError.new(message)
  end
  parsed.store(:stream, true)
  thread_id =
    parsed.delete(:thread_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :post,
    path: ["threads/%1$s/runs/%2$s/submit_tool_outputs", thread_id, run_id],
    headers: {"accept" => "text/event-stream"},
    body: parsed,
    stream: OpenAI::Internal::Stream,
    model: OpenAI::Beta::AssistantStreamEvent,
    options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  )
end

#update(run_id, thread_id:, metadata: nil, request_options: {}) ⇒ OpenAI::Models::Beta::Threads::Run

Deprecated.

The Assistants API is deprecated in favor of the Responses API

Some parameter documentations has been truncated, see Models::Beta::Threads::RunUpdateParams for more details.

Modifies a run.

Parameters:

  • Path param: The ID of the run to modify.

  • Path param: The ID of the [thread](platform.openai.com/docs/api-referenc

  • Body param: Set of 16 key-value pairs that can be attached to an object. This ca

Returns:

See Also:



212
213
214
215
216
217
218
219
220
221
222
223
224
225
# File 'lib/openai/resources/beta/threads/runs.rb', line 212

def update(run_id, params)
  parsed, options = OpenAI::Beta::Threads::RunUpdateParams.dump_request(params)
  thread_id =
    parsed.delete(:thread_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :post,
    path: ["threads/%1$s/runs/%2$s", thread_id, run_id],
    body: parsed,
    model: OpenAI::Beta::Threads::Run,
    options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  )
end