feat: implement models endpoint

This commit is contained in:
2026-09-30 00:56:09 -04:00
parent c6c0849cf5
commit f0e8516d7a
3 changed files with 72 additions and 5 deletions

43
src/openai/models.rs Normal file
View File

@@ -0,0 +1,43 @@
use serde::{Deserialize, Serialize};
/// The object type, which is always "model".
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum ModelObject {
Model,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Model<Id> {
/// The model identifier, which can be referenced in the API endpoints.
pub id: Id,
/// The Unix timestamp (in seconds) when the model was created.
pub created: i64,
/// The object type, which is always "model".
pub object: ModelObject,
/// The organization that owns the model.
pub owned_by: String,
/// The date when the model will shut down, or null if not announced.
#[serde(skip_serializing_if = "Option::is_none")]
pub shutdown_date: Option<String>,
}
/// The object type, which is always "list".
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum ListObject {
List,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ListModelsResponse<Id> {
/// The list of currently available models.
pub data: Vec<Model<Id>>,
/// The object type, which is always "list".
pub object: ListObject,
}