pub struct OpenRouterImageProvider { /* private fields */ }Expand description
Provider for the OpenRouter image API.
// From `OPENROUTER_API_KEY` and, if set, `OPENROUTER_BASE_URL`
let provider = OpenRouterImageProvider::from_env("bytedance-seed/seedream-4.5")?;
// Or everything in code
let provider =
OpenRouterImageProvider::new("bytedance-seed/seedream-4.5", "sk-or-...", DEFAULT_BASE_URL);Implementations§
Source§impl OpenRouterImageProvider
impl OpenRouterImageProvider
Sourcepub fn new(
model: impl Into<String>,
api_key: impl Into<String>,
base_url: impl Into<String>,
) -> Self
pub fn new( model: impl Into<String>, api_key: impl Into<String>, base_url: impl Into<String>, ) -> Self
Creates a provider for model with the API key and base URL given in code, for example
DEFAULT_BASE_URL.
Sourcepub fn from_env(model: impl Into<String>) -> Result<Self, ImageError>
pub fn from_env(model: impl Into<String>) -> Result<Self, ImageError>
Creates a provider for model with the API key from OPENROUTER_API_KEY and the base
URL from OPENROUTER_BASE_URL, or DEFAULT_BASE_URL when it is not set.
Trait Implementations§
Source§impl Clone for OpenRouterImageProvider
impl Clone for OpenRouterImageProvider
Source§impl Debug for OpenRouterImageProvider
impl Debug for OpenRouterImageProvider
Source§impl ImageProvider for OpenRouterImageProvider
impl ImageProvider for OpenRouterImageProvider
Source§fn edit<'life0, 'async_trait>(
&'life0 self,
request: ImageEditRequest,
) -> Pin<Box<dyn Future<Output = Result<ImageResponse, ImageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn edit<'life0, 'async_trait>(
&'life0 self,
request: ImageEditRequest,
) -> Pin<Box<dyn Future<Output = Result<ImageResponse, ImageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Sends the images as input_references; models that do not take input images answer
with an API error.
Source§fn list_models<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<ImageModel>, ImageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list_models<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<ImageModel>, ImageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Lists the models that output images, following every page of the list.
Source§fn generate<'life0, 'async_trait>(
&'life0 self,
request: ImageRequest,
) -> Pin<Box<dyn Future<Output = Result<ImageResponse, ImageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn generate<'life0, 'async_trait>(
&'life0 self,
request: ImageRequest,
) -> Pin<Box<dyn Future<Output = Result<ImageResponse, ImageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Generates an image.
Source§fn supports_edit(&self) -> bool
fn supports_edit(&self) -> bool
Returns
true when the provider implements edit.Auto Trait Implementations§
impl !RefUnwindSafe for OpenRouterImageProvider
impl !UnwindSafe for OpenRouterImageProvider
impl Freeze for OpenRouterImageProvider
impl Send for OpenRouterImageProvider
impl Sync for OpenRouterImageProvider
impl Unpin for OpenRouterImageProvider
impl UnsafeUnpin for OpenRouterImageProvider
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