pub struct Endpoint {
pub address: String,
pub model: String,
pub key_header: String,
pub key: Key,
}Expand description
A provider speaking the Anthropic Messages shape.
Fields§
§address: StringThe address the API lives under, such as https://api.example.com/anthropic; requests go
to {address}/v1/messages.
model: StringThe model asked for.
key_header: StringThe header the key goes in: x-api-key for most, another name for some servers. For
authorization the key goes in as a bearer token.
key: KeyThe key.
Implementations§
Source§impl Endpoint
impl Endpoint
Sourcepub fn url(&self) -> String
pub fn url(&self) -> String
Where a message request goes. The key is never part of it, so it is safe to show.
Sourcepub fn stream(
&self,
body: &Value,
on_delta: &mut dyn FnMut(Delta),
cancelled: &dyn Fn() -> bool,
) -> Result<Reply, ProviderError>
pub fn stream( &self, body: &Value, on_delta: &mut dyn FnMut(Delta), cancelled: &dyn Fn() -> bool, ) -> Result<Reply, ProviderError>
Sends body (a Messages request without model and stream, which are added here) and
reads the streamed reply, handing each piece to on_delta as it arrives. cancelled is
asked between events.
§Errors
When the server cannot be reached, refuses, or answers with something that is not a Messages reply. No error carries the key.
Trait Implementations§
impl Eq for Endpoint
impl StructuralPartialEq for Endpoint
Auto Trait Implementations§
impl Freeze for Endpoint
impl RefUnwindSafe for Endpoint
impl Send for Endpoint
impl Sync for Endpoint
impl Unpin for Endpoint
impl UnsafeUnpin for Endpoint
impl UnwindSafe for Endpoint
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more