pub struct OpenAiAdapter { /* private fields */ }Expand description
OpenAI Chat Completions adapter.
Implementations§
Source§impl OpenAiAdapter
impl OpenAiAdapter
pub fn new(api_key: impl Into<String>) -> Self
Sourcepub fn from_env() -> Result<Self, ModelError>
pub fn from_env() -> Result<Self, ModelError>
Create adapter from OPENAI_API_KEY env var.
Sourcepub fn with_base_url(self, base_url: impl Into<String>) -> Self
pub fn with_base_url(self, base_url: impl Into<String>) -> Self
Override the base URL (for OpenAI-compatible APIs).
pub fn with_default_model(self, model: impl Into<String>) -> Self
Trait Implementations§
Source§impl ModelAdapter for OpenAiAdapter
impl ModelAdapter for OpenAiAdapter
Source§fn system_name(&self) -> &'static str
fn system_name(&self) -> &'static str
OTel GenAI system name (e.g. “anthropic”, “openai”).
Source§fn default_model(&self) -> &str
fn default_model(&self) -> &str
Default model for this adapter (e.g. “claude-sonnet-4-6”).
Source§fn chat<'life0, 'async_trait>(
&'life0 self,
request: ModelRequest,
) -> Pin<Box<dyn Future<Output = Result<ModelResponse, ModelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn chat<'life0, 'async_trait>(
&'life0 self,
request: ModelRequest,
) -> Pin<Box<dyn Future<Output = Result<ModelResponse, ModelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Send a chat request and return the response.
Source§fn structured_output<'life0, 'async_trait>(
&'life0 self,
request: StructuredRequest,
) -> Pin<Box<dyn Future<Output = Result<ModelResponse, ModelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn structured_output<'life0, 'async_trait>(
&'life0 self,
request: StructuredRequest,
) -> Pin<Box<dyn Future<Output = Result<ModelResponse, ModelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Send a structured output request, returning a JSON value. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for OpenAiAdapter
impl !UnwindSafe for OpenAiAdapter
impl Freeze for OpenAiAdapter
impl Send for OpenAiAdapter
impl Sync for OpenAiAdapter
impl Unpin for OpenAiAdapter
impl UnsafeUnpin for OpenAiAdapter
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
Mutably borrows from an owned value. Read more