pub struct ChatGptClient { /* private fields */ }Expand description
OpenAI API client.
Implementations§
Source§impl ChatGptClient
impl ChatGptClient
Sourcepub fn new(api_key: &str, model: &str) -> Result<Self>
pub fn new(api_key: &str, model: &str) -> Result<Self>
Create a new client. The API key is baked into the underlying
reqwest::Client as a default header so it doesn’t need to be
cloned per-request.
Sourcepub fn with_max_output_tokens(self, n: u32) -> Self
pub fn with_max_output_tokens(self, n: u32) -> Self
Override the maximum number of output tokens per response.
Sourcepub fn with_reasoning_effort(self, effort: &str) -> Self
pub fn with_reasoning_effort(self, effort: &str) -> Self
Override the default reasoning effort level.
Valid values: "minimal", "low", "medium", "high".
Sourcepub async fn create_response(
&self,
input: &[Value],
instructions: Option<&str>,
tools: Option<&[ToolDefinition]>,
previous_response_id: Option<&str>,
) -> Result<ApiResponse, LlmError>
pub async fn create_response( &self, input: &[Value], instructions: Option<&str>, tools: Option<&[ToolDefinition]>, previous_response_id: Option<&str>, ) -> Result<ApiResponse, LlmError>
Send a blocking request to the Responses API.
Returns the full parsed response including output items and usage.
The agent loop inspects function_calls() to decide whether to
execute tools or return the final answer.
Sourcepub fn create_response_stream(
&self,
input: &[Value],
instructions: Option<&str>,
tools: Option<&[ToolDefinition]>,
previous_response_id: Option<&str>,
) -> impl Stream<Item = Result<ResponseStreamEvent, LlmError>> + Send
pub fn create_response_stream( &self, input: &[Value], instructions: Option<&str>, tools: Option<&[ToolDefinition]>, previous_response_id: Option<&str>, ) -> impl Stream<Item = Result<ResponseStreamEvent, LlmError>> + Send
Stream a response from the Responses API, yielding structured events.
Returns a stream of ResponseStreamEvents: text deltas, function calls,
and a final ResponseCompleted with the response ID (for chaining) and
token usage.
The returned stream is 'static – it clones the HTTP client and model
name so callers don’t need to worry about lifetimes.
Trait Implementations§
Source§impl Clone for ChatGptClient
impl Clone for ChatGptClient
Source§fn clone(&self) -> ChatGptClient
fn clone(&self) -> ChatGptClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ChatGptClient
impl !RefUnwindSafe for ChatGptClient
impl Send for ChatGptClient
impl Sync for ChatGptClient
impl Unpin for ChatGptClient
impl UnsafeUnpin for ChatGptClient
impl !UnwindSafe for ChatGptClient
Blanket Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more