Skip to main content

openai_compat/types/
models.rs

1//! Model types, mirroring `openai-python/src/openai/types/model.py`.
2
3use serde::{Deserialize, Serialize};
4
5use crate::pagination::HasId;
6
7/// A model available through the API.
8#[derive(Debug, Clone, Serialize, Deserialize)]
9#[non_exhaustive]
10pub struct Model {
11    pub id: String,
12    #[serde(default)]
13    pub created: Option<i64>,
14    #[serde(default)]
15    pub object: String,
16    #[serde(default)]
17    pub owned_by: Option<String>,
18}
19
20impl HasId for Model {
21    fn id(&self) -> Option<&str> {
22        Some(&self.id)
23    }
24}
25
26/// Response from `DELETE` endpoints (`{ id, deleted, object }`).
27#[derive(Debug, Clone, Serialize, Deserialize)]
28#[non_exhaustive]
29pub struct Deleted {
30    pub id: String,
31    pub deleted: bool,
32    #[serde(default)]
33    pub object: String,
34}