pub struct RunsApi { /* private fields */ }Expand description
OpenAI Runs API client for managing assistant run execution
Implementations§
Source§impl RunsApi
impl RunsApi
Sourcepub fn with_base_url<S: Into<String>>(api_key: S, base_url: S) -> Result<Self>
pub fn with_base_url<S: Into<String>>(api_key: S, base_url: S) -> Result<Self>
Sourcepub async fn create_run<S: AsRef<str>>(
&self,
thread_id: S,
request: RunRequest,
) -> Result<Run>
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 runrequest- 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);Sourcepub async fn create_thread_and_run(
&self,
request: CreateThreadAndRunRequest,
) -> Result<Run>
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);Sourcepub async fn retrieve_run<S: AsRef<str>, R: AsRef<str>>(
&self,
thread_id: S,
run_id: R,
) -> Result<Run>
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 threadrun_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);Sourcepub async fn modify_run<S: AsRef<str>, R: AsRef<str>>(
&self,
thread_id: S,
run_id: R,
request: ModifyRunRequest,
) -> Result<Run>
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 threadrun_id- The ID of the run to modifyrequest- 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);Sourcepub async fn list_runs<S: AsRef<str>>(
&self,
thread_id: S,
params: Option<ListRunsParams>,
) -> Result<ListRunsResponse>
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 threadparams- 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());Sourcepub async fn submit_tool_outputs<S: AsRef<str>, R: AsRef<str>>(
&self,
thread_id: S,
run_id: R,
request: SubmitToolOutputsRequest,
) -> Result<Run>
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 threadrun_id- The ID of the runrequest- 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);Sourcepub async fn cancel_run<S: AsRef<str>, R: AsRef<str>>(
&self,
thread_id: S,
run_id: R,
) -> Result<Run>
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 threadrun_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);Sourcepub async fn list_run_steps<S: AsRef<str>, R: AsRef<str>>(
&self,
thread_id: S,
run_id: R,
params: Option<ListRunStepsParams>,
) -> Result<ListRunStepsResponse>
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 threadrun_id- The ID of the runparams- 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());Sourcepub 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>
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 threadrun_id- The ID of the runstep_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);Sourcepub async fn submit_tool_outputs_stream<S: AsRef<str>, R: AsRef<str>>(
&self,
thread_id: S,
run_id: R,
request: SubmitToolOutputsRequest,
) -> Result<Run>
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 threadrun_id- The ID of the runrequest- 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);Sourcepub async fn create_run_stream<S: AsRef<str>>(
&self,
thread_id: S,
request: RunRequest,
) -> Result<Run>
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 runrequest- 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);Sourcepub async fn create_thread_and_run_stream(
&self,
request: CreateThreadAndRunRequest,
) -> Result<Run>
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
impl ApiClientConstructors for RunsApi
Source§fn from_http_client(http_client: HttpClient) -> Self
fn from_http_client(http_client: HttpClient) -> Self
Create a new instance with the HTTP client
Auto Trait Implementations§
impl Freeze for RunsApi
impl !RefUnwindSafe for RunsApi
impl Send for RunsApi
impl Sync for RunsApi
impl Unpin for RunsApi
impl !UnwindSafe for RunsApi
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more