RunsApi

Struct RunsApi 

Source
pub struct RunsApi { /* private fields */ }
Expand description

OpenAI Runs API client for managing assistant run execution

Implementations§

Source§

impl RunsApi

Source

pub fn with_base_url<S: Into<String>>(api_key: S, base_url: S) -> Result<Self>

Creates a new Runs API client with a custom base URL

§Arguments
  • api_key - Your OpenAI API key
  • base_url - Custom API base URL
§Example
use openai_rust_sdk::api::{runs::RunsApi, common::ApiClientConstructors};

let api = RunsApi::with_base_url("your-api-key", "https://api.openai.com")?;
Source

pub async fn create_run<S: AsRef<str>>( &self, thread_id: S, request: RunRequest, ) -> Result<Run>

Create a run

§Arguments
  • thread_id - The ID of the thread to run
  • request - The run request parameters
§Example
use openai_rust_sdk::api::{runs::RunsApi, common::ApiClientConstructors};
use openai_rust_sdk::models::runs::RunRequest;

let api = RunsApi::new("your-api-key")?;
let request = RunRequest::builder()
    .assistant_id("asst_abc123")
    .instructions("Please analyze the data.")
    .build()?;

let run = api.create_run("thread_abc123", request).await?;
println!("Created run: {}", run.id);
Source

pub async fn create_thread_and_run( &self, request: CreateThreadAndRunRequest, ) -> Result<Run>

Create a thread and run it in one request

§Arguments
  • request - The thread and run request parameters
§Example
use openai_rust_sdk::api::{runs::RunsApi, common::ApiClientConstructors};
use openai_rust_sdk::models::runs::CreateThreadAndRunRequest;

let api = RunsApi::new("your-api-key")?;
let request = CreateThreadAndRunRequest::builder()
    .assistant_id("asst_abc123")
    .instructions("Please help me with this task.")
    .build()?;

let run = api.create_thread_and_run(request).await?;
println!("Created thread and run: {} in thread {}", run.id, run.thread_id);
Source

pub async fn retrieve_run<S: AsRef<str>, R: AsRef<str>>( &self, thread_id: S, run_id: R, ) -> Result<Run>

Retrieve a run

§Arguments
  • thread_id - The ID of the thread
  • run_id - The ID of the run to retrieve
§Example
use openai_rust_sdk::api::{runs::RunsApi, common::ApiClientConstructors};

let api = RunsApi::new("your-api-key")?;
let run = api.retrieve_run("thread_abc123", "run_abc123").await?;
println!("Run status: {:?}", run.status);
Source

pub async fn modify_run<S: AsRef<str>, R: AsRef<str>>( &self, thread_id: S, run_id: R, request: ModifyRunRequest, ) -> Result<Run>

Modify a run

§Arguments
  • thread_id - The ID of the thread
  • run_id - The ID of the run to modify
  • request - The modification request
§Example
use openai_rust_sdk::api::{runs::RunsApi, common::ApiClientConstructors};
use openai_rust_sdk::models::runs::ModifyRunRequest;
use std::collections::HashMap;

let api = RunsApi::new("your-api-key")?;
let mut metadata = HashMap::new();
metadata.insert("updated".to_string(), "true".to_string());
let request = ModifyRunRequest { metadata: Some(metadata) };

let run = api.modify_run("thread_abc123", "run_abc123", request).await?;
println!("Modified run: {}", run.id);
Source

pub async fn list_runs<S: AsRef<str>>( &self, thread_id: S, params: Option<ListRunsParams>, ) -> Result<ListRunsResponse>

List runs in a thread

§Arguments
  • thread_id - The ID of the thread
  • params - Optional pagination parameters
§Example
use openai_rust_sdk::api::{runs::RunsApi, common::ApiClientConstructors};
use openai_rust_sdk::models::runs::ListRunsParams;

let api = RunsApi::new("your-api-key")?;
let params = ListRunsParams { limit: Some(10), ..Default::default() };
let response = api.list_runs("thread_abc123", Some(params)).await?;
println!("Found {} runs", response.data.len());
Source

pub async fn submit_tool_outputs<S: AsRef<str>, R: AsRef<str>>( &self, thread_id: S, run_id: R, request: SubmitToolOutputsRequest, ) -> Result<Run>

Submit tool outputs to a run

§Arguments
  • thread_id - The ID of the thread
  • run_id - The ID of the run
  • request - The tool outputs to submit
§Example
use openai_rust_sdk::api::{runs::RunsApi, common::ApiClientConstructors};
use openai_rust_sdk::models::runs::{SubmitToolOutputsRequest, ToolOutput};

let api = RunsApi::new("your-api-key")?;
let request = SubmitToolOutputsRequest {
    tool_outputs: vec![
        ToolOutput {
            tool_call_id: "call_abc123".to_string(),
            output: "The result is 42".to_string(),
        }
    ],
};

let run = api.submit_tool_outputs("thread_abc123", "run_abc123", request).await?;
println!("Submitted tool outputs to run: {}", run.id);
Source

pub async fn cancel_run<S: AsRef<str>, R: AsRef<str>>( &self, thread_id: S, run_id: R, ) -> Result<Run>

Cancel a run

§Arguments
  • thread_id - The ID of the thread
  • run_id - The ID of the run to cancel
§Example
use openai_rust_sdk::api::{runs::RunsApi, common::ApiClientConstructors};

let api = RunsApi::new("your-api-key")?;
let run = api.cancel_run("thread_abc123", "run_abc123").await?;
println!("Cancelled run: {}", run.id);
Source

pub async fn list_run_steps<S: AsRef<str>, R: AsRef<str>>( &self, thread_id: S, run_id: R, params: Option<ListRunStepsParams>, ) -> Result<ListRunStepsResponse>

List run steps in a run

§Arguments
  • thread_id - The ID of the thread
  • run_id - The ID of the run
  • params - Optional pagination parameters
§Example
use openai_rust_sdk::api::{runs::RunsApi, common::ApiClientConstructors};
use openai_rust_sdk::models::runs::ListRunStepsParams;

let api = RunsApi::new("your-api-key")?;
let params = ListRunStepsParams { limit: Some(10), ..Default::default() };
let response = api.list_run_steps("thread_abc123", "run_abc123", Some(params)).await?;
println!("Found {} run steps", response.data.len());
Source

pub async fn retrieve_run_step<S: AsRef<str>, R: AsRef<str>, T: AsRef<str>>( &self, thread_id: S, run_id: R, step_id: T, ) -> Result<RunStep>

Retrieve a run step

§Arguments
  • thread_id - The ID of the thread
  • run_id - The ID of the run
  • step_id - The ID of the run step to retrieve
§Example
use openai_rust_sdk::api::{runs::RunsApi, common::ApiClientConstructors};

let api = RunsApi::new("your-api-key")?;
let step = api.retrieve_run_step("thread_abc123", "run_abc123", "step_abc123").await?;
println!("Run step status: {:?}", step.status);
Source

pub async fn submit_tool_outputs_stream<S: AsRef<str>, R: AsRef<str>>( &self, thread_id: S, run_id: R, request: SubmitToolOutputsRequest, ) -> Result<Run>

Submit tool outputs with streaming

§Arguments
  • thread_id - The ID of the thread
  • run_id - The ID of the run
  • request - The tool outputs to submit
§Example
use openai_rust_sdk::api::{runs::RunsApi, common::ApiClientConstructors};
use openai_rust_sdk::models::runs::{SubmitToolOutputsRequest, ToolOutput};

let api = RunsApi::new("your-api-key")?;
let request = SubmitToolOutputsRequest {
    tool_outputs: vec![
        ToolOutput {
            tool_call_id: "call_abc123".to_string(),
            output: "The result is 42".to_string(),
        }
    ],
};

let run = api.submit_tool_outputs_stream("thread_abc123", "run_abc123", request).await?;
println!("Submitted tool outputs with streaming to run: {}", run.id);
Source

pub async fn create_run_stream<S: AsRef<str>>( &self, thread_id: S, request: RunRequest, ) -> Result<Run>

Create a run with streaming

§Arguments
  • thread_id - The ID of the thread to run
  • request - The run request parameters
§Example
use openai_rust_sdk::api::{runs::RunsApi, common::ApiClientConstructors};
use openai_rust_sdk::models::runs::RunRequest;

let api = RunsApi::new("your-api-key")?;
let request = RunRequest::builder()
    .assistant_id("asst_abc123")
    .instructions("Please analyze the data.")
    .build()?;

let run = api.create_run_stream("thread_abc123", request).await?;
println!("Created streaming run: {}", run.id);
Source

pub async fn create_thread_and_run_stream( &self, request: CreateThreadAndRunRequest, ) -> Result<Run>

Create a thread and run with streaming

§Arguments
  • request - The thread and run request parameters
§Example
use openai_rust_sdk::api::{runs::RunsApi, common::ApiClientConstructors};
use openai_rust_sdk::models::runs::CreateThreadAndRunRequest;

let api = RunsApi::new("your-api-key")?;
let request = CreateThreadAndRunRequest::builder()
    .assistant_id("asst_abc123")
    .instructions("Please help me with this task.")
    .build()?;

let run = api.create_thread_and_run_stream(request).await?;
println!("Created streaming thread and run: {} in thread {}", run.id, run.thread_id);

Trait Implementations§

Source§

impl ApiClientConstructors for RunsApi

Source§

fn from_http_client(http_client: HttpClient) -> Self

Create a new instance with the HTTP client
Source§

fn new<S: Into<String>>(api_key: S) -> Result<Self>

Creates a new API client Read more
Source§

fn new_with_base_url<S: Into<String>>(api_key: S, base_url: S) -> Result<Self>

Creates a new API client with custom base URL Read more
Source§

impl Clone for RunsApi

Source§

fn clone(&self) -> RunsApi

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RunsApi

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,