1use serde::{Deserialize, Serialize};
7
8#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
10pub struct CreditsResponse {
11 #[serde(default)]
13 pub data: CreditsData,
14}
15
16#[derive(Clone, Copy, Debug, Default, PartialEq, Serialize, Deserialize)]
18pub struct CreditsData {
19 #[serde(default)]
21 pub total_credits: f64,
22 #[serde(default)]
24 pub total_usage: f64,
25}
26
27impl CreditsData {
28 pub fn remaining(&self) -> f64 {
30 self.total_credits - self.total_usage
31 }
32}
33
34#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
36pub struct KeyResponse {
37 #[serde(default)]
39 pub data: KeyData,
40}
41
42#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
44pub struct KeyData {
45 #[serde(default)]
47 pub label: String,
48 #[serde(default)]
50 pub limit: Option<f64>,
51 #[serde(default)]
53 pub usage: f64,
54 #[serde(default)]
56 pub is_free_tier: bool,
57 #[serde(default)]
59 pub limit_remaining: Option<f64>,
60 #[serde(default)]
62 pub is_provisioning_key: bool,
63 #[serde(default)]
65 pub rate_limit: Option<KeyRateLimit>,
66}
67
68#[derive(Clone, Debug, Default, PartialEq, Eq)]
70pub struct ActivityOptions {
71 pub date: Option<String>,
74}
75
76impl ActivityOptions {
77 pub fn new() -> Self {
79 Self::default()
80 }
81
82 pub fn date(mut self, date: impl Into<String>) -> Self {
84 self.date = Some(date.into());
85 self
86 }
87
88 pub(crate) fn to_query(&self) -> Vec<(&'static str, String)> {
89 let mut q = Vec::new();
90 if let Some(d) = &self.date {
91 q.push(("date", d.clone()));
92 }
93 q
94 }
95}
96
97#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
99pub struct ActivityResponse {
100 #[serde(default)]
102 pub data: Vec<ActivityData>,
103}
104
105#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
107pub struct ActivityData {
108 #[serde(default)]
110 pub date: String,
111 #[serde(default)]
113 pub model: String,
114 #[serde(default)]
116 pub model_permaslug: String,
117 #[serde(default)]
119 pub endpoint_id: String,
120 #[serde(default)]
122 pub provider_name: String,
123 #[serde(default)]
125 pub usage: f64,
126 #[serde(default)]
128 pub byok_usage_inference: f64,
129 #[serde(default)]
131 pub requests: f64,
132 #[serde(default)]
134 pub prompt_tokens: f64,
135 #[serde(default)]
137 pub completion_tokens: f64,
138 #[serde(default)]
140 pub reasoning_tokens: f64,
141}
142
143#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
145pub struct ListKeysOptions {
146 pub offset: Option<u32>,
148 pub include_disabled: Option<bool>,
150}
151
152impl ListKeysOptions {
153 pub fn new() -> Self {
155 Self::default()
156 }
157
158 pub fn offset(mut self, offset: u32) -> Self {
160 self.offset = Some(offset);
161 self
162 }
163
164 pub fn include_disabled(mut self, include: bool) -> Self {
166 self.include_disabled = Some(include);
167 self
168 }
169
170 pub(crate) fn to_query(self) -> Vec<(&'static str, String)> {
171 let mut q = Vec::new();
172 if let Some(o) = self.offset {
173 q.push(("offset", o.to_string()));
174 }
175 if let Some(i) = self.include_disabled {
176 q.push(("include_disabled", i.to_string()));
177 }
178 q
179 }
180}
181
182#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
184pub struct ListKeysResponse {
185 #[serde(default)]
187 pub data: Vec<ApiKey>,
188}
189
190#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
195pub struct ApiKey {
196 #[serde(default)]
198 pub name: String,
199 #[serde(default)]
201 pub label: String,
202 #[serde(default)]
204 pub limit: f64,
205 #[serde(default)]
207 pub disabled: bool,
208 #[serde(default)]
210 pub created_at: String,
211 #[serde(default)]
213 pub updated_at: String,
214 #[serde(default)]
218 pub hash: String,
219}
220
221#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
223pub struct CreateKeyRequest {
224 pub name: String,
226 #[serde(skip_serializing_if = "Option::is_none", default)]
228 pub limit: Option<f64>,
229 #[serde(skip_serializing_if = "Option::is_none", default)]
231 pub include_byok_in_limit: Option<bool>,
232}
233
234#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
237pub struct CreateKeyResponse {
238 #[serde(default)]
240 pub data: ApiKey,
241 #[serde(default, skip_serializing_if = "Option::is_none")]
244 pub key: Option<String>,
245}
246
247#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
249pub struct GetKeyByHashResponse {
250 #[serde(default)]
252 pub data: ApiKey,
253}
254
255#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
258pub struct UpdateKeyRequest {
259 #[serde(skip_serializing_if = "Option::is_none", default)]
261 pub name: Option<String>,
262 #[serde(skip_serializing_if = "Option::is_none", default)]
264 pub disabled: Option<bool>,
265 #[serde(skip_serializing_if = "Option::is_none", default)]
267 pub limit: Option<f64>,
268 #[serde(skip_serializing_if = "Option::is_none", default)]
270 pub include_byok_in_limit: Option<bool>,
271}
272
273#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
275pub struct UpdateKeyResponse {
276 #[serde(default)]
278 pub data: ApiKey,
279}
280
281#[derive(Clone, Copy, Debug, Default, PartialEq, Serialize, Deserialize)]
283pub struct DeleteKeyResponse {
284 #[serde(default)]
286 pub data: DeleteKeyData,
287}
288
289#[derive(Clone, Copy, Debug, Default, PartialEq, Serialize, Deserialize)]
291pub struct DeleteKeyData {
292 #[serde(default)]
294 pub success: bool,
295}
296
297#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
299pub struct KeyRateLimit {
300 #[serde(default)]
302 pub interval: String,
303 #[serde(default)]
305 pub requests: f64,
306}