Skip to main content

gproxy_protocol/wire/claude/
models.rs

1use serde::{Deserialize, Serialize};
2
3use crate::Rest;
4
5/// Request/response shapes for `GET /v1/models` and `GET /v1/models/{model_id}`.
6/// `after_id`, `before_id`, and `limit` are query parameters; `anthropic_beta`
7/// is the repeated `anthropic-beta` request header; `model_id` is a path
8/// parameter. Source: `upstream_docs/claude/docs/List Models.md` and
9/// `Get a Model.md`.
10#[derive(
11    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
12)]
13#[serde(rename_all = "snake_case")]
14#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
15#[derive(gproxy_protocol_macros::DeclaredFields)]
16pub struct ListModelsQuery {
17    #[serde(skip_serializing_if = "Option::is_none")]
18    pub after_id: Option<String>,
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub before_id: Option<String>,
21    #[serde(skip_serializing_if = "Option::is_none")]
22    pub limit: Option<i64>,
23    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
24    pub rest: Rest,
25}
26
27pub type ListModelsRequest = crate::WireRequest<()>;
28pub type GetModelRequest = crate::WireRequest<()>;
29
30#[derive(
31    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
32)]
33#[serde(rename_all = "snake_case")]
34#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
35#[derive(gproxy_protocol_macros::DeclaredFields)]
36pub struct ListModelsResponseBody {
37    pub data: Vec<ModelInfo>,
38    pub first_id: String,
39    pub has_more: bool,
40    pub last_id: String,
41    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
42    pub rest: Rest,
43}
44
45pub type ListModelsResponse = crate::WireResponse<ListModelsResponseBody>;
46pub type GetModelResponse = crate::WireResponse<ModelInfo>;
47
48#[derive(
49    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
50)]
51#[serde(rename_all = "snake_case")]
52#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
53#[derive(gproxy_protocol_macros::DeclaredFields)]
54pub struct ModelInfo {
55    pub id: String,
56    #[serde(default)]
57    pub allowed_fallback_models: Vec<String>,
58    pub capabilities: ModelCapabilities,
59    pub created_at: String,
60    pub display_name: String,
61    pub max_input_tokens: i64,
62    pub max_tokens: i64,
63    #[serde(rename = "type")]
64    pub type_: ModelType,
65    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
66    pub rest: Rest,
67}
68
69#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
70#[serde(rename_all = "snake_case")]
71#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
72#[derive(gproxy_protocol_macros::DeclaredFields)]
73pub enum ModelType {
74    Model,
75}
76
77#[derive(
78    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
79)]
80#[serde(rename_all = "snake_case")]
81#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
82#[derive(gproxy_protocol_macros::DeclaredFields)]
83pub struct ModelCapabilities {
84    pub batch: CapabilitySupport,
85    pub citations: CapabilitySupport,
86    pub code_execution: CapabilitySupport,
87    pub context_management: ContextManagementCapability,
88    pub effort: EffortCapability,
89    pub image_input: CapabilitySupport,
90    pub pdf_input: CapabilitySupport,
91    pub structured_outputs: CapabilitySupport,
92    pub thinking: ThinkingCapability,
93    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
94    pub rest: Rest,
95}
96
97#[derive(
98    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
99)]
100#[serde(rename_all = "snake_case")]
101#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
102#[derive(gproxy_protocol_macros::DeclaredFields)]
103pub struct CapabilitySupport {
104    pub supported: bool,
105    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
106    pub rest: Rest,
107}
108
109#[derive(
110    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
111)]
112#[serde(rename_all = "snake_case")]
113#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
114#[derive(gproxy_protocol_macros::DeclaredFields)]
115pub struct ContextManagementCapability {
116    pub clear_thinking_20251015: CapabilitySupport,
117    pub clear_tool_uses_20250919: CapabilitySupport,
118    pub compact_20260112: CapabilitySupport,
119    pub supported: bool,
120    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
121    pub rest: Rest,
122}
123
124#[derive(
125    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
126)]
127#[serde(rename_all = "snake_case")]
128#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
129#[derive(gproxy_protocol_macros::DeclaredFields)]
130pub struct EffortCapability {
131    pub high: CapabilitySupport,
132    pub low: CapabilitySupport,
133    pub max: CapabilitySupport,
134    pub medium: CapabilitySupport,
135    pub supported: bool,
136    pub xhigh: CapabilitySupport,
137    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
138    pub rest: Rest,
139}
140
141#[derive(
142    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
143)]
144#[serde(rename_all = "snake_case")]
145#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
146#[derive(gproxy_protocol_macros::DeclaredFields)]
147pub struct ThinkingCapability {
148    pub supported: bool,
149    pub types: ThinkingTypes,
150    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
151    pub rest: Rest,
152}
153
154#[derive(
155    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder,
156)]
157#[serde(rename_all = "snake_case")]
158#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
159#[derive(gproxy_protocol_macros::DeclaredFields)]
160pub struct ThinkingTypes {
161    pub adaptive: CapabilitySupport,
162    pub enabled: CapabilitySupport,
163    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
164    pub rest: Rest,
165}