Skip to main content

OpenRouterBuilder

Struct OpenRouterBuilder 

Source
pub struct OpenRouterBuilder<M = WithoutModel, W = Responses, T: Transport = ReqwestTransport> { /* private fields */ }

Implementations§

Source§

impl OpenRouterBuilder<WithoutModel, Responses, ReqwestTransport>

Source

pub fn new() -> Self

Source§

impl<M, W, T: Transport> OpenRouterBuilder<M, W, T>

Source

pub fn with_api_key(self, api_key: impl Into<String>) -> Self

Override the API key. If unset, OPENROUTER_API_KEY is read at build time.

Source

pub fn with_base_url(self, url: impl Into<String>) -> Self

Override the base URL. Defaults to https://openrouter.ai/api/v1.

Source

pub fn with_description(self, description: impl Into<String>) -> Self

Source

pub fn with_transport<T2: Transport>( self, transport: T2, ) -> OpenRouterBuilder<M, W, T2>

Supply a custom transport, replacing the default ReqwestTransport.

Source§

impl<W, T: Transport> OpenRouterBuilder<WithoutModel, W, T>

Source

pub fn with_model( self, model: impl Into<String>, ) -> OpenRouterBuilder<WithModel, W, T>

Select the model. OpenRouter slugs are vendor-prefixed, e.g. anthropic/claude-sonnet-4 or openai/gpt-4o.

Source§

impl<M, T: Transport> OpenRouterBuilder<M, Responses, T>

Source

pub fn with_completions(self) -> OpenRouterBuilder<M, Completions, T>

Opt in to the Chat Completions wire instead of the default Responses API.

Source

pub fn with_reasoning_effort(self, effort: impl Into<String>) -> Self

Set the reasoning effort ("low" / "medium" / "high") for reasoning-capable models. Responses-wire only — Chat Completions does not carry this field.

Source§

impl<T: Transport> OpenRouterBuilder<WithModel, Responses, T>

Source

pub fn build(self) -> ResponsesClient<T>

Build a Responses API client.

Source§

impl<T: Transport> OpenRouterBuilder<WithModel, Completions, T>

Source

pub fn build(self) -> CompletionsClient<T>

Build a Chat Completions client.

Trait Implementations§

Source§

impl Default for OpenRouterBuilder<WithoutModel, Responses, ReqwestTransport>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<M, W, T> Freeze for OpenRouterBuilder<M, W, T>
where T: Freeze,

§

impl<M, W, T> RefUnwindSafe for OpenRouterBuilder<M, W, T>

§

impl<M, W, T> Send for OpenRouterBuilder<M, W, T>
where M: Send, W: Send,

§

impl<M, W, T> Sync for OpenRouterBuilder<M, W, T>
where M: Sync, W: Sync,

§

impl<M, W, T> Unpin for OpenRouterBuilder<M, W, T>
where T: Unpin, M: Unpin, W: Unpin,

§

impl<M, W, T> UnsafeUnpin for OpenRouterBuilder<M, W, T>
where T: UnsafeUnpin,

§

impl<M, W, T> UnwindSafe for OpenRouterBuilder<M, W, T>
where T: UnwindSafe, M: UnwindSafe, W: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<M> MetaArg<M> for M

Source§

fn into_meta(self) -> M

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more