pub struct AnthropicProvider { /* private fields */ }Expand description
Anthropic Claude API provider.
Supports Claude 3.5 Sonnet, Claude 3.5 Haiku, and other Claude models.
Implementations§
Source§impl AnthropicProvider
impl AnthropicProvider
pub fn into_reference( val: AnthropicProvider, env: Env, ) -> Result<Reference<AnthropicProvider>>
pub fn into_instance(self, env: Env) -> Result<ClassInstance<AnthropicProvider>>
Source§impl AnthropicProvider
impl AnthropicProvider
Sourcepub fn new(api_key: String) -> Self
pub fn new(api_key: String) -> Self
Create a new Anthropic provider with API key.
§Arguments
api_key- Your Anthropic API key (starts with “sk-ant-”)
Sourcepub fn with_base_url(api_key: String, base_url: String) -> Self
pub fn with_base_url(api_key: String, base_url: String) -> Self
Create a provider with custom base URL.
Useful for proxies or custom endpoints.
Sourcepub async fn list_models(&self) -> Result<Vec<String>>
pub async fn list_models(&self) -> Result<Vec<String>>
List available models.
Returns an array of model IDs like “claude-3-5-sonnet-20241022”.
Sourcepub async fn complete(
&self,
request: JsCompletionRequest,
) -> Result<JsCompletionResponse>
pub async fn complete( &self, request: JsCompletionRequest, ) -> Result<JsCompletionResponse>
Sourcepub fn complete_stream(
&self,
request: JsCompletionRequest,
callback: JsFunction,
) -> Result<()>
pub fn complete_stream( &self, request: JsCompletionRequest, callback: JsFunction, ) -> Result<()>
Create a streaming completion.
The callback is called for each chunk received. Chunks have:
chunk_type: “content_block_delta”, “message_stop”, etc.delta: Text content (for delta chunks)stop_reason: Why generation stopped (for final chunk)
§Arguments
request- The completion requestcallback- Function called with (error, chunk) for each chunk
Trait Implementations§
Source§impl FromNapiMutRef for AnthropicProvider
impl FromNapiMutRef for AnthropicProvider
Source§unsafe fn from_napi_mut_ref(
env: napi_env,
napi_val: napi_value,
) -> Result<&'static mut Self>
unsafe fn from_napi_mut_ref( env: napi_env, napi_val: napi_value, ) -> Result<&'static mut Self>
Safety Read more
Source§impl FromNapiRef for AnthropicProvider
impl FromNapiRef for AnthropicProvider
Source§unsafe fn from_napi_ref(
env: napi_env,
napi_val: napi_value,
) -> Result<&'static Self>
unsafe fn from_napi_ref( env: napi_env, napi_val: napi_value, ) -> Result<&'static Self>
Safety Read more
Source§impl FromNapiValue for &AnthropicProvider
impl FromNapiValue for &AnthropicProvider
Source§unsafe fn from_napi_value(env: napi_env, napi_val: napi_value) -> Result<Self>
unsafe fn from_napi_value(env: napi_env, napi_val: napi_value) -> Result<Self>
Safety Read more
fn from_unknown(value: JsUnknown) -> Result<Self, Error>
Source§impl FromNapiValue for &mut AnthropicProvider
impl FromNapiValue for &mut AnthropicProvider
Source§unsafe fn from_napi_value(env: napi_env, napi_val: napi_value) -> Result<Self>
unsafe fn from_napi_value(env: napi_env, napi_val: napi_value) -> Result<Self>
Safety Read more
fn from_unknown(value: JsUnknown) -> Result<Self, Error>
Source§impl ObjectFinalize for AnthropicProvider
impl ObjectFinalize for AnthropicProvider
Source§impl ToNapiValue for AnthropicProvider
impl ToNapiValue for AnthropicProvider
Source§unsafe fn to_napi_value(
env: napi_env,
val: AnthropicProvider,
) -> Result<napi_value>
unsafe fn to_napi_value( env: napi_env, val: AnthropicProvider, ) -> Result<napi_value>
Safety Read more
Source§impl TypeName for &AnthropicProvider
impl TypeName for &AnthropicProvider
Source§impl TypeName for &mut AnthropicProvider
impl TypeName for &mut AnthropicProvider
Source§impl TypeName for AnthropicProvider
impl TypeName for AnthropicProvider
Source§impl ValidateNapiValue for &AnthropicProvider
impl ValidateNapiValue for &AnthropicProvider
Source§unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
Safety Read more
Source§impl ValidateNapiValue for &mut AnthropicProvider
impl ValidateNapiValue for &mut AnthropicProvider
Source§unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
Safety Read more
Auto Trait Implementations§
impl Freeze for AnthropicProvider
impl !RefUnwindSafe for AnthropicProvider
impl Send for AnthropicProvider
impl Sync for AnthropicProvider
impl Unpin for AnthropicProvider
impl !UnwindSafe for AnthropicProvider
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