Skip to main content

StreamOptions

Struct StreamOptions 

Source
pub struct StreamOptions {
Show 16 fields pub api_key: Option<String>, pub headers: IndexMap<String, Option<String>>, pub reasoning: Option<ThinkingLevel>, pub max_tokens: Option<u64>, pub temperature: Option<f64>, pub session_id: Option<String>, pub transport: Option<Transport>, pub websocket_connect_timeout_ms: Option<u64>, pub timeout_ms: Option<f64>, pub cache_retention: Option<CacheRetention>, pub thinking_budgets: ThinkingBudgets, pub max_retries: u32, pub max_retry_delay_ms: Option<u64>, pub cancel: CancellationToken, pub env: Option<ProviderEnv>, pub hooks: RequestHooks,
}
Expand description

Request options shared by every wire API.

Fields§

§api_key: Option<String>

Credential for the provider. Some providers take headers instead.

§headers: IndexMap<String, Option<String>>

Extra headers. None removes a header the provider would otherwise send.

§reasoning: Option<ThinkingLevel>

Thinking effort. None and Off disable thinking where the API allows.

§max_tokens: Option<u64>

Output token limit, or the model’s limit when absent.

§temperature: Option<f64>

Sampling temperature, where the model and thinking mode allow it.

§session_id: Option<String>

Stable id for provider-side session affinity and caching.

§transport: Option<Transport>

Preferred transport for providers that offer more than one. The provider’s default when absent.

§websocket_connect_timeout_ms: Option<u64>

How long opening a WebSocket may take, in milliseconds. 0 waits forever. The provider’s default when absent.

§timeout_ms: Option<f64>

pi’s timeoutMs: how long a request may wait, in milliseconds, as each provider applies it. The provider’s default when absent. A number, as the settings hold it, so a provider that validates it can report an invalid one as pi does.

§cache_retention: Option<CacheRetention>

Prompt cache retention. PI_CACHE_RETENTION=long or short when absent.

§thinking_budgets: ThinkingBudgets

Token budgets per level for budget-based thinking.

§max_retries: u32

Retries for retryable HTTP errors before the first byte. 0 disables them.

§max_retry_delay_ms: Option<u64>

Largest server-requested retry delay to honor. 0 means no limit.

§cancel: CancellationToken

Cancels the request, and the stream then ends with an aborted error.

§env: Option<ProviderEnv>

Provider settings from the credential, such as a Cloudflare account id or an AWS profile, read ahead of the process environment.

§hooks: RequestHooks

Observers of the request.

Implementations§

Source§

impl StreamOptions

Source

pub fn resolved_cache_retention(&self) -> CacheRetention

The cache retention to use: Self::requested_cache_retention, else short.

Source

pub fn requested_cache_retention(&self) -> Option<CacheRetention>

The option, else long when PI_CACHE_RETENTION=long in env or the process environment.

Source

pub fn has_header(&self, name: &str) -> bool

Whether headers sets name (case-insensitive) to a non-blank value.

Trait Implementations§

Source§

impl Clone for StreamOptions

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for StreamOptions

Source§

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

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

impl Default for StreamOptions

Source§

fn default() -> Self

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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