Skip to main content

gproxy_protocol/wire/openai/responses/
diagnostics.rs

1//! Responses prompt-cache diagnostics (September 2026 API reference).
2use crate::Rest;
3use serde::{Deserialize, Serialize};
4
5#[derive(
6    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::DeclaredFields,
7)]
8#[serde(tag = "type", rename_all = "snake_case")]
9#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
10pub enum PromptCacheDiagnostics {
11    CacheMiss(CacheMiss),
12    CacheHit(DiagnosticOutcome),
13    ComparisonResponseNotFound(DiagnosticOutcome),
14    Unavailable(DiagnosticOutcome),
15}
16
17#[derive(
18    Debug,
19    Clone,
20    PartialEq,
21    Eq,
22    Serialize,
23    Deserialize,
24    gproxy_protocol_macros::WireBuilder,
25    gproxy_protocol_macros::DeclaredFields,
26)]
27#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
28pub struct CacheMiss {
29    pub cache_missed_tokens: i64,
30    pub reason: CacheMissReason,
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub comparison_reusable_tokens: Option<i64>,
33    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
34    pub rest: Rest,
35}
36
37#[derive(
38    Debug,
39    Clone,
40    PartialEq,
41    Eq,
42    Serialize,
43    Deserialize,
44    gproxy_protocol_macros::WireBuilder,
45    gproxy_protocol_macros::DeclaredFields,
46)]
47#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
48pub struct DiagnosticOutcome {
49    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
50    pub rest: Rest,
51}
52
53#[derive(
54    Debug,
55    Clone,
56    Copy,
57    PartialEq,
58    Eq,
59    Serialize,
60    Deserialize,
61    gproxy_protocol_macros::DeclaredFields,
62)]
63#[serde(rename_all = "snake_case")]
64#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
65pub enum CacheMissReason {
66    ModelChanged,
67    PromptCacheKeyChanged,
68    ServiceTierChanged,
69    ToolsChanged,
70    TextFormatChanged,
71    ReasoningEffortChanged,
72    VerbosityChanged,
73    ContextCompacted,
74    InputChanged,
75}