pub struct RequestUsageConfig {
pub include: bool,
}Expand description
OpenRouter’s request-side “return detailed usage” directive (response-side cache-usage fix).
Why: Requesting detailed usage accounting is what makes OpenRouter return
its authoritative, already cache-discount-aware usage.cost field (and
the nested prompt_tokens_details cache counters) on the response —
without it, only the bare prompt/completion/total counts are guaranteed.
Sent only for the OpenRouter provider (agent_loop::build_request); other
providers (direct/Bedrock) never see this field.
What: include: true serialises to the wire shape {"include":true}
under the request’s top-level usage key.
Test: request_usage_config_detailed_serialises_expected_shape,
chat_request_with_detailed_usage_serialises.
Fields§
§include: boolWhether to request detailed (cost + cache-breakdown) usage accounting.
Implementations§
Source§impl RequestUsageConfig
impl RequestUsageConfig
Sourcepub fn detailed() -> Self
pub fn detailed() -> Self
Construct the “include detailed usage” directive.
Why: Every call site wants the identical {"include":true} value;
naming the constructor after the wire concept avoids a bare true
literal scattered at call sites.
What: Returns RequestUsageConfig { include: true }.
Test: request_usage_config_detailed_serialises_expected_shape.
Trait Implementations§
Source§impl Clone for RequestUsageConfig
impl Clone for RequestUsageConfig
Source§fn clone(&self) -> RequestUsageConfig
fn clone(&self) -> RequestUsageConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RequestUsageConfig
impl Debug for RequestUsageConfig
Source§impl<'de> Deserialize<'de> for RequestUsageConfig
impl<'de> Deserialize<'de> for RequestUsageConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for RequestUsageConfig
impl PartialEq for RequestUsageConfig
Source§impl Serialize for RequestUsageConfig
impl Serialize for RequestUsageConfig
impl StructuralPartialEq for RequestUsageConfig
Auto Trait Implementations§
impl Freeze for RequestUsageConfig
impl RefUnwindSafe for RequestUsageConfig
impl Send for RequestUsageConfig
impl Sync for RequestUsageConfig
impl Unpin for RequestUsageConfig
impl UnsafeUnpin for RequestUsageConfig
impl UnwindSafe for RequestUsageConfig
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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