pub struct Client { /* private fields */ }Expand description
Sends decision requests. Debug isn’t derived, to keep the key out of logs.
Implementations§
Source§impl Client
impl Client
Sourcepub fn new(key: &str) -> Client
pub fn new(key: &str) -> Client
A client for OpenRouter with an API key. An empty key sends no Authorization header, for an
endpoint (see Client::with_url) that adds the key itself.
Sourcepub fn with_url(self, url: &str) -> Client
pub fn with_url(self, url: &str) -> Client
Sends requests to url instead of OpenRouter’s decisions endpoint.
Sourcepub fn with_model(self, model: &str) -> Client
pub fn with_model(self, model: &str) -> Client
Asks model instead of DEFAULT_MODEL.
Sourcepub async fn decide<K: Into<String>>(
&self,
state: impl Serialize,
questions: impl IntoIterator<Item = (K, Question)>,
) -> Result<DecisionResponse>
pub async fn decide<K: Into<String>>( &self, state: impl Serialize, questions: impl IntoIterator<Item = (K, Question)>, ) -> Result<DecisionResponse>
Asks questions, under their ids, about state.
Sourcepub fn request<K: Into<String>>(
&self,
state: impl Serialize,
questions: impl IntoIterator<Item = (K, Question)>,
) -> Result<DecisionRequest>
pub fn request<K: Into<String>>( &self, state: impl Serialize, questions: impl IntoIterator<Item = (K, Question)>, ) -> Result<DecisionRequest>
The request Client::decide sends.
Sourcepub async fn send(&self, request: &DecisionRequest) -> Result<DecisionResponse>
pub async fn send(&self, request: &DecisionRequest) -> Result<DecisionResponse>
Sends request as it is, whatever model it names.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Client
impl !UnwindSafe for Client
impl Freeze for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl UnsafeUnpin for Client
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