openai-interface 0.13.0

A low-level Rust interface for the OpenAI API
Documentation
//! List and describe the various models available in the API.
//!
//! Submodules: `list`, `retrieve`, and `delete` for specific model operations.

pub mod delete;
pub mod list;
pub mod retrieve;

use serde::{Deserialize, Serialize};

/// Describes an OpenAI model offering that can be used with the API.
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct Model {
    /// The model identifier, which can be referenced in the API endpoints.
    pub id: String,
    /// The Unix timestamp (in seconds) when the model was created.
    ///
    /// OpenAI returns this field, but some OpenAI-compatible providers omit
    /// it (e.g. DeepSeek, verified against the live `GET /models` endpoint).
    pub created: Option<u64>,
    /// 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.
    ///
    /// Note: OpenAI-compatible providers may omit this field.
    pub shutdown_date: Option<String>,

    /// vLLM: the artifact this entry was loaded from — a Hugging Face repo
    /// id or a local snapshot path. Equals `id` for a plain served model.
    #[cfg(feature = "vllm")]
    pub root: Option<String>,
    /// vLLM: the base model this entry derives from. `null` for a plain
    /// served model; for a LoRA adapter served via the JSON `--lora-modules`
    /// form it names the base model.
    #[cfg(feature = "vllm")]
    pub parent: Option<String>,
    /// vLLM: the context window of the served model, in tokens.
    #[cfg(feature = "vllm")]
    pub max_model_len: Option<u64>,
}

#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq)]
#[serde(rename_all = "lowercase")]
pub enum ModelObject {
    Model,
}

crate::impl_from_str!(Model);