InferenceConfig

Struct InferenceConfig 

Source
pub struct InferenceConfig { /* private fields */ }
Expand description

Provider configuration for Inference client

Allows configuring multiple AI providers with their API keys and base URLs.

§Example

use stakai::{Inference, InferenceConfig};

let client = Inference::with_config(
    InferenceConfig::new()
        .openai("sk-...", None)
        .anthropic("sk-ant-...", None)
        .gemini("your-key", None)
);

Implementations§

Source§

impl InferenceConfig

Source

pub fn new() -> Self

Create a new inference configuration

Source

pub fn openai( self, api_key: impl Into<String>, base_url: Option<String>, ) -> Self

Configure OpenAI provider with API key and optional base URL

§Example
let config = InferenceConfig::new()
    .openai("sk-...", None);

// With custom base URL (e.g., Azure OpenAI)
let config = InferenceConfig::new()
    .openai("sk-...", Some("https://your-endpoint.openai.azure.com/v1".to_string()));
Source

pub fn openai_config(self, config: OpenAIConfig) -> Self

Configure OpenAI provider with full OpenAIConfig

§Example
let openai_config = OpenAIConfig::new("sk-...")
    .with_base_url("https://custom.com/v1")
    .with_organization("org-123");

let config = InferenceConfig::new()
    .openai_config(openai_config);
Source

pub fn anthropic( self, api_key: impl Into<String>, base_url: Option<String>, ) -> Self

Configure Anthropic provider with API key and optional base URL

§Example
let config = InferenceConfig::new()
    .anthropic("sk-ant-...", None);

// With custom base URL
let config = InferenceConfig::new()
    .anthropic("sk-ant-...", Some("https://custom-anthropic.com/v1".to_string()));
Source

pub fn anthropic_config(self, config: AnthropicConfig) -> Self

Configure Anthropic provider with full AnthropicConfig

§Example
let anthropic_config = AnthropicConfig::new("sk-ant-...")
    .with_version("2023-06-01")
    .with_beta_feature("prompt-caching-2024-07-31");

let config = InferenceConfig::new()
    .anthropic_config(anthropic_config);
Source

pub fn gemini( self, api_key: impl Into<String>, base_url: Option<String>, ) -> Self

Configure Gemini provider with API key and optional base URL

§Example
let config = InferenceConfig::new()
    .gemini("your-api-key", None);

// With custom base URL
let config = InferenceConfig::new()
    .gemini("your-key", Some("https://custom-gemini.com/v1beta".to_string()));
Source

pub fn gemini_config(self, config: GeminiConfig) -> Self

Configure Gemini provider with full GeminiConfig

§Example
let gemini_config = GeminiConfig::new("your-key")
    .with_base_url("https://custom.com/v1beta");

let config = InferenceConfig::new()
    .gemini_config(gemini_config);
Source

pub fn temperature(self, temperature: f32) -> Self

Set default temperature for all requests

Source

pub fn max_tokens(self, max_tokens: u32) -> Self

Set default max tokens for all requests

Source

pub fn timeout(self, seconds: u64) -> Self

Set request timeout in seconds

Trait Implementations§

Source§

impl Debug for InferenceConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for InferenceConfig

Source§

fn default() -> InferenceConfig

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

Auto Trait Implementations§

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<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