Skip to main content

openai_interface/models/
mod.rs

1//! List and describe the various models available in the API.
2//!
3//! Submodules: `list`, `retrieve`, and `delete` for specific model operations.
4
5pub mod delete;
6pub mod list;
7pub mod retrieve;
8
9use serde::{Deserialize, Serialize};
10
11/// Describes an OpenAI model offering that can be used with the API.
12#[derive(Debug, Deserialize, Serialize, Clone)]
13pub struct Model {
14    /// The model identifier, which can be referenced in the API endpoints.
15    pub id: String,
16    /// The Unix timestamp (in seconds) when the model was created.
17    ///
18    /// OpenAI returns this field, but some OpenAI-compatible providers omit
19    /// it (e.g. DeepSeek, verified against the live `GET /models` endpoint).
20    pub created: Option<u64>,
21    /// The object type, which is always `model`.
22    pub object: ModelObject,
23    /// The organization that owns the model.
24    pub owned_by: String,
25    /// The date when the model will shut down, or null if not announced.
26    ///
27    /// Note: OpenAI-compatible providers may omit this field.
28    pub shutdown_date: Option<String>,
29
30    /// vLLM: the artifact this entry was loaded from — a Hugging Face repo
31    /// id or a local snapshot path. Equals `id` for a plain served model.
32    #[cfg(feature = "vllm")]
33    pub root: Option<String>,
34    /// vLLM: the base model this entry derives from. `null` for a plain
35    /// served model; for a LoRA adapter served via the JSON `--lora-modules`
36    /// form it names the base model.
37    #[cfg(feature = "vllm")]
38    pub parent: Option<String>,
39    /// vLLM: the context window of the served model, in tokens.
40    #[cfg(feature = "vllm")]
41    pub max_model_len: Option<u64>,
42}
43
44#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq)]
45#[serde(rename_all = "lowercase")]
46pub enum ModelObject {
47    Model,
48}
49
50crate::impl_from_str!(Model);