pub struct OpenAIChatDriver { /* private fields */ }Expand description
OpenAI Chat Driver using Open Responses API
Production driver for OpenAI using the Open Responses specification (https://www.openresponses.org/). This is the recommended driver for new projects, offering:
- Better performance with reasoning models (o1, o3, GPT-5)
- Provider-agnostic streaming events
- Native agentic loop support
- 40-80% better cache utilization
For backward compatibility with the Chat Completions API, use
OpenAICompletionsChatDriver instead.
§Example
use everruns_openai::OpenAIChatDriver;
let driver = OpenAIChatDriver::new("your-api-key");
// With custom endpoint
let driver = OpenAIChatDriver::with_base_url(
"your-api-key",
"https://api.example.com/v1/responses",
);Implementations§
Source§impl OpenAIChatDriver
impl OpenAIChatDriver
Sourcepub fn with_base_url(
api_key: impl Into<String>,
api_url: impl Into<String>,
) -> Self
pub fn with_base_url( api_key: impl Into<String>, api_url: impl Into<String>, ) -> Self
Create a new driver with a custom API URL
Sourcepub fn uses_custom_url(&self) -> bool
pub fn uses_custom_url(&self) -> bool
Check if using a custom base URL
Sourcepub async fn compact_conversation(
&self,
request: CompactRequest,
) -> Result<CompactResponse>
pub async fn compact_conversation( &self, request: CompactRequest, ) -> Result<CompactResponse>
Compact a conversation to reduce context size
This method calls the /v1/responses/compact endpoint to compress the conversation history. User messages are kept verbatim, while assistant messages, tool calls, and tool results are replaced by an encrypted compaction item.
§Arguments
request- The compact request containing the model and input items
§Returns
Returns a CompactResponse containing the compacted output items.
The output can be used directly as input for the next /v1/responses call.
Sourcepub fn can_compact(&self) -> bool
pub fn can_compact(&self) -> bool
Check if this driver supports the compact endpoint
Returns true for OpenAI’s Responses API. Custom endpoints may or may not support compaction.
Trait Implementations§
Source§impl ChatDriver for OpenAIChatDriver
impl ChatDriver for OpenAIChatDriver
Source§fn chat_completion_stream<'life0, 'life1, 'async_trait>(
&'life0 self,
messages: Vec<LlmMessage>,
config: &'life1 LlmCallConfig,
) -> Pin<Box<dyn Future<Output = Result<LlmResponseStream>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn chat_completion_stream<'life0, 'life1, 'async_trait>(
&'life0 self,
messages: Vec<LlmMessage>,
config: &'life1 LlmCallConfig,
) -> Pin<Box<dyn Future<Output = Result<LlmResponseStream>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn list_models<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<DiscoveredModel>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list_models<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<DiscoveredModel>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn supports_compact(&self) -> bool
fn supports_compact(&self) -> bool
Source§fn supports_parallel_tool_calls(&self, model: &str) -> bool
fn supports_parallel_tool_calls(&self, model: &str) -> bool
parallel_tool_calls
preference on the wire for model. Read moreSource§fn compact<'life0, 'async_trait>(
&'life0 self,
request: CompactRequest,
) -> Pin<Box<dyn Future<Output = Result<Option<CompactResponse>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn compact<'life0, 'async_trait>(
&'life0 self,
request: CompactRequest,
) -> Pin<Box<dyn Future<Output = Result<Option<CompactResponse>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn chat_completion<'life0, 'life1, 'async_trait>(
&'life0 self,
messages: Vec<LlmMessage>,
config: &'life1 LlmCallConfig,
) -> Pin<Box<dyn Future<Output = Result<LlmResponse, AgentLoopError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn chat_completion<'life0, 'life1, 'async_trait>(
&'life0 self,
messages: Vec<LlmMessage>,
config: &'life1 LlmCallConfig,
) -> Pin<Box<dyn Future<Output = Result<LlmResponse, AgentLoopError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Source§fn supports_stateful_responses(&self) -> bool
fn supports_stateful_responses(&self) -> bool
previous_response_id. Read moreSource§impl Clone for OpenAIChatDriver
impl Clone for OpenAIChatDriver
Source§fn clone(&self) -> OpenAIChatDriver
fn clone(&self) -> OpenAIChatDriver
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more