{
  "name": "forge-provider-openai",
  "language": "rust",
  "version": "0.2.0",
  "description": "OpenAI provider for the Forge SDK \u2014 implements the LanguageModel trait for OpenAI ChatCompletion API",
  "manifest": "forge-rs/crates/forge-provider-openai/Cargo.toml",
  "manifestSha256": "f90ffd081fff1c6dbc481539d5d6f2dec8116854555bd2796c9c4e24db699cab",
  "status": "source-reference",
  "registryPublicationVerified": false,
  "route": "/libraries/rust/forge-provider-openai",
  "features": {},
  "files": [
    {
      "path": "forge-rs/crates/forge-provider-openai/src/client.rs",
      "sha256": "5829bf861c0772e914d7043a1685bf7c1434483c6da50094bd1f1811b4c3d22b",
      "artifactSha256": "771035dd66de76a3a7274fac803a2c1d2796faad71544c1e4e69899e3b1ca402",
      "url": "/reference/source/forge-rs/crates/forge-provider-openai/src/client.rs.txt",
      "declarations": []
    },
    {
      "path": "forge-rs/crates/forge-provider-openai/src/config.rs",
      "sha256": "668964c68fbef1e1b6f3b854fd79870af67f3fe4bedeccc751f1349a83d4b625",
      "artifactSha256": "f92d3b3aa3862e9610f060ac9aa6611690c18bca2aeb2cb45fe7ceade9edfffa",
      "url": "/reference/source/forge-rs/crates/forge-provider-openai/src/config.rs.txt",
      "declarations": [
        {
          "name": "::OpenAiConfig",
          "line": 55,
          "signature": "#[derive(Clone)]\npub struct OpenAiConfig {\n\n}",
          "documentation": "Configuration for connecting to the OpenAI API.\n\nContains the API key, base URL, optional organization header, timeout,\nand retry settings.\n\n# Security\n\nThe `Debug` implementation **always** redacts the API key. The key is\nnever written to logs, error messages, or debug output.\n\n# Examples\n\n```\nuse forge_provider_openai::OpenAiConfig;\n\nlet config = OpenAiConfig::builder(\"sk-test-key-123\").build();\nlet debug_output = format!(\"{:?}\", config);\nassert!(!debug_output.contains(\"sk-test-key-123\"));\nassert!(debug_output.contains(\"[REDACTED]\"));\n```"
        },
        {
          "name": "::OpenAiConfig::builder",
          "line": 87,
          "signature": "pub fn builder(api_key: impl Into<String>) -> OpenAiConfigBuilder;",
          "documentation": "Creates a new configuration builder.\n\n# Arguments\n\n* `api_key` - The OpenAI API key. This is required and cannot be empty.\n\n# Returns\n\nAn `OpenAiConfigBuilder` with default values for all optional fields.\n\n# Examples\n\n```\nuse forge_provider_openai::OpenAiConfig;\n\nlet config = OpenAiConfig::builder(\"sk-my-key\").build();\nassert_eq!(config.base_url(), \"https://api.openai.com/v1\");\n```"
        },
        {
          "name": "::OpenAiConfig::base_url",
          "line": 112,
          "signature": "pub fn base_url(&self) -> &str;",
          "documentation": "Returns the base URL for API requests.\n\n# Returns\n\nThe configured base URL (e.g., `\"https://api.openai.com/v1\"`)."
        },
        {
          "name": "::OpenAiConfig::organization",
          "line": 121,
          "signature": "pub fn organization(&self) -> Option<&str>;",
          "documentation": "Returns the optional organization identifier.\n\n# Returns\n\n`Some(&str)` if an organization was configured, `None` otherwise."
        },
        {
          "name": "::OpenAiConfig::timeout_seconds",
          "line": 126,
          "signature": "pub fn timeout_seconds(&self) -> u64;",
          "documentation": "Returns the request timeout in seconds."
        },
        {
          "name": "::OpenAiConfig::max_retries",
          "line": 131,
          "signature": "pub fn max_retries(&self) -> u32;",
          "documentation": "Returns the maximum number of retries for transient errors."
        },
        {
          "name": "::OpenAiConfigBuilder",
          "line": 165,
          "signature": "pub struct OpenAiConfigBuilder {\n\n}",
          "documentation": "Builder for [`OpenAiConfig`].\n\nAll optional fields have sensible defaults:\n- `base_url`: `\"https://api.openai.com/v1\"`\n- `timeout_seconds`: `60`\n- `max_retries`: `3`\n\n# Examples\n\n```\nuse forge_provider_openai::OpenAiConfig;\n\nlet config = OpenAiConfig::builder(\"sk-key\")\n    .base_url(\"https://custom-proxy.example.com/v1\")\n    .timeout_seconds(90)\n    .build();\n```"
        },
        {
          "name": "::OpenAiConfigBuilder::base_url",
          "line": 184,
          "signature": "pub fn base_url(mut self, url: impl Into<String>) -> Self;",
          "documentation": "Sets the base URL for API requests.\n\n# Arguments\n\n* `url` - The base URL (e.g., `\"https://api.openai.com/v1\"`).\n  Trailing slashes are stripped.\n\n# Returns\n\nThe builder for chaining."
        },
        {
          "name": "::OpenAiConfigBuilder::organization",
          "line": 199,
          "signature": "pub fn organization(mut self, org: impl Into<String>) -> Self;",
          "documentation": "Sets the organization identifier for multi-org accounts.\n\n# Arguments\n\n* `org` - The organization ID (e.g., `\"org-abc123\"`).\n\n# Returns\n\nThe builder for chaining."
        },
        {
          "name": "::OpenAiConfigBuilder::timeout_seconds",
          "line": 213,
          "signature": "pub fn timeout_seconds(mut self, seconds: u64) -> Self;",
          "documentation": "Sets the request timeout in seconds.\n\n# Arguments\n\n* `seconds` - Timeout duration. Must be greater than 0.\n\n# Returns\n\nThe builder for chaining."
        },
        {
          "name": "::OpenAiConfigBuilder::max_retries",
          "line": 230,
          "signature": "pub fn max_retries(mut self, retries: u32) -> Self;",
          "documentation": "Sets the maximum number of retries for transient errors.\n\nRetries are attempted for HTTP 429 (rate limit) and 5xx (server error)\nresponses, using exponential backoff with jitter.\n\n# Arguments\n\n* `retries` - Maximum retry count. Set to 0 to disable retries.\n\n# Returns\n\nThe builder for chaining."
        },
        {
          "name": "::OpenAiConfigBuilder::build",
          "line": 240,
          "signature": "pub fn build(self) -> OpenAiConfig;",
          "documentation": "Builds the [`OpenAiConfig`].\n\n# Returns\n\nThe configured `OpenAiConfig` instance."
        }
      ]
    },
    {
      "path": "forge-rs/crates/forge-provider-openai/src/error.rs",
      "sha256": "6b0f971c10b6415cceb05f77a3e0a5d6de346f65a61dd121e746fea1e61312c1",
      "artifactSha256": "48e605681c8c2e6c9569409e145d8cd6a6439e3d3af8c946657ae5b1a03e85c8",
      "url": "/reference/source/forge-rs/crates/forge-provider-openai/src/error.rs.txt",
      "declarations": [
        {
          "name": "::OpenAiError",
          "line": 30,
          "signature": "#[derive(Debug, Error)]\npub enum OpenAiError {\n    /// The OpenAI API returned an HTTP error response.\n    ///\n    /// Common status codes:\n    /// - 400: malformed request (check message format)\n    /// - 401: invalid API key\n    /// - 403: insufficient permissions\n    /// - 404: model not found\n    /// - 429: rate limited\n    /// - 500+: server error (retryable)\n    #[error(\n        \"OpenAI API returned HTTP {status}: {body} (check request format and API key permissions)\"\n    )]\n    HttpError {\n        /// The HTTP status code.\n        status: u16,\n        /// The response body (may contain OpenAI error details).\n        body: String,\n    },\n\n    /// Failed to connect to the OpenAI API endpoint.\n    ///\n    /// Check network connectivity, firewall rules, and the configured base URL.\n    #[error(\"failed to connect to OpenAI API at '{url}': {reason} (check network connectivity and base_url configuration)\")]\n    ConnectionFailed {\n        /// The URL that was being connected to.\n        url: String,\n        /// The underlying connection error.\n        reason: String,\n    },\n\n    /// The request timed out waiting for a response.\n    ///\n    /// Consider increasing `timeout_seconds` in `OpenAiConfig` or reducing\n    /// `max_tokens` to speed up generation.\n    #[error(\"OpenAI API request to '{url}' timed out after {timeout_seconds}s (consider increasing timeout_seconds in OpenAiConfig or reducing max_tokens)\")]\n    Timeout {\n        /// The URL that timed out.\n        url: String,\n        /// The configured timeout in seconds.\n        timeout_seconds: u64,\n    },\n\n    /// The API response could not be parsed.\n    ///\n    /// This typically indicates an API version mismatch or an unexpected\n    /// response format. Check the OpenAI API changelog for breaking changes.\n    #[error(\"invalid response from OpenAI API: {reason} (this may indicate an API version mismatch; check the OpenAI API changelog)\")]\n    InvalidResponse {\n        /// Description of what was wrong with the response.\n        reason: String,\n    },\n\n    /// The API returned a rate limit error (HTTP 429).\n    ///\n    /// The provider will automatically retry with exponential backoff. If this\n    /// error surfaces, all retries have been exhausted.\n    #[error(\"OpenAI API rate limited; all retries exhausted{}\", match .retry_after_ms {\n        Some(ms) => format!(\" (server suggested retry after {ms}ms)\"),\n        None => String::new(),\n    })]\n    RateLimited {\n        /// Milliseconds to wait before retrying, if provided by the server.\n        retry_after_ms: Option<u64>,\n    },\n\n    /// Authentication failed (HTTP 401).\n    ///\n    /// The API key is invalid, expired, or missing.\n    #[error(\"OpenAI API authentication failed: {hint}\")]\n    AuthenticationFailed {\n        /// Actionable hint for resolving the auth issue.\n        hint: String,\n    },\n\n    /// An error occurred while parsing the SSE stream.\n    ///\n    /// This may indicate a network interruption during streaming or an\n    /// unexpected stream format.\n    #[error(\"OpenAI streaming error: {reason}\")]\n    StreamError {\n        /// Description of the stream parsing failure.\n        reason: String,\n    },\n\n    /// JSON serialization or deserialization failed.\n    ///\n    /// This typically means a request or response struct is malformed.\n    #[error(\"JSON serialization error: {0}\")]\n    SerializationError(#[from] serde_json::Error),\n\n    /// The request could not be constructed.\n    ///\n    /// This indicates an internal error in request building.\n    #[error(\"failed to build HTTP request: {reason}\")]\n    RequestBuildError {\n        /// Description of the request construction failure.\n        reason: String,\n    },\n}",
          "documentation": "Errors specific to the OpenAI provider.\n\nEach variant includes actionable context: what failed, why, and what\nthe developer should check.\n\n# Examples\n\n```\nuse forge_provider_openai::OpenAiError;\n\nlet err = OpenAiError::AuthenticationFailed {\n    hint: \"check that OPENAI_API_KEY is set and valid\".to_string(),\n};\nassert!(err.to_string().contains(\"OPENAI_API_KEY\"));\n```"
        }
      ]
    },
    {
      "path": "forge-rs/crates/forge-provider-openai/src/lib.rs",
      "sha256": "b2ed35a2d5e409a8a23683a9d6af61a52f840d7ebe3c9389744fc49cefdc1343",
      "artifactSha256": "2799e31465a56599b59bdca651a3afa2c8af60571fcef4eb4539e704efd6aa4c",
      "url": "/reference/source/forge-rs/crates/forge-provider-openai/src/lib.rs.txt",
      "declarations": [
        {
          "name": "client",
          "line": 57,
          "signature": "#[cfg(not(target_arch = \"wasm32\"))]\npub mod client;",
          "documentation": "# forge-provider-openai\n\nOpenAI provider for the Forge SDK, implementing the `LanguageModel` trait\nfrom `forge-core` for the [OpenAI ChatCompletion API](https://platform.openai.com/docs/api-reference/chat).\n\nThis crate translates between Forge's provider-agnostic message types and\nOpenAI's API format. It handles authentication, retries with exponential\nbackoff, SSE streaming, and structured output via `response_format`.\n\n# ANVIL Spec Reference\n\nANVIL Spec \u00a76.1 \u2014 Cognitive Interface: this provider satisfies the\n`LanguageModel` contract for the `openai` namespace.\n\n# Supported Models\n\n- `gpt-4o`, `gpt-4o-mini` \u2014 full feature set (tools, images, streaming, structured output)\n- `o1`, `o3`, `o3-mini`, `o4-mini` \u2014 reasoning models (limited temperature/system support)\n- `gpt-4-turbo`, `gpt-3.5-turbo` \u2014 legacy models\n\n# Examples\n\n```no_run\nuse forge_provider_openai::{OpenAiLanguageModel, OpenAiConfig};\nuse forge_core::model::LanguageModel;\nuse forge_core::message::{ModelMessage, Role};\nuse forge_core::config::GenerateOptions;\n\n# async fn example() -> Result<(), Box<dyn std::error::Error>> {\nlet config = OpenAiConfig::builder(\"sk-your-api-key\")\n    .base_url(\"https://api.openai.com/v1\")\n    .build();\n\nlet model = OpenAiLanguageModel::new(\"gpt-4o\".to_string(), config)?;\n\nlet messages = vec![\n    ModelMessage::text(Role::System, \"You are a helpful assistant.\"),\n    ModelMessage::text(Role::User, \"What is 2+2?\"),\n];\n\nlet result = model.generate(&messages, &[], &GenerateOptions::default()).await?;\nprintln!(\"{}\", result.text());\n# Ok(())\n# }\n```\n\n# Security\n\n- API keys are **never** logged. The `Debug` implementation for `OpenAiConfig`\n  redacts the key.\n- All HTTP communication uses TLS via `hyper-tls`.\n- No `unsafe` code \u2014 enforced via `#![forbid(unsafe_code)]`."
        },
        {
          "name": "config",
          "line": 59,
          "signature": "#[cfg(not(target_arch = \"wasm32\"))]\npub mod config;",
          "documentation": ""
        },
        {
          "name": "error",
          "line": 60,
          "signature": "pub mod error;",
          "documentation": ""
        },
        {
          "name": "model",
          "line": 62,
          "signature": "#[cfg(not(target_arch = \"wasm32\"))]\npub mod model;",
          "documentation": ""
        },
        {
          "name": "sse",
          "line": 64,
          "signature": "#[cfg(not(target_arch = \"wasm32\"))]\npub mod sse;",
          "documentation": ""
        },
        {
          "name": "types",
          "line": 65,
          "signature": "pub mod types;",
          "documentation": ""
        },
        {
          "name": "pub use config::{OpenAiConfig, OpenAiConfigBuilder};",
          "line": 68,
          "signature": "#[cfg(not(target_arch = \"wasm32\"))]\npub use config::{OpenAiConfig, OpenAiConfigBuilder};",
          "documentation": ""
        },
        {
          "name": "pub use error::OpenAiError;",
          "line": 69,
          "signature": "pub use error::OpenAiError;",
          "documentation": ""
        },
        {
          "name": "pub use model::OpenAiLanguageModel;",
          "line": 71,
          "signature": "#[cfg(not(target_arch = \"wasm32\"))]\npub use model::OpenAiLanguageModel;",
          "documentation": ""
        }
      ]
    },
    {
      "path": "forge-rs/crates/forge-provider-openai/src/model.rs",
      "sha256": "63f9fdc57e6484c3ae0c23060f7c86b58db7477e8b9a48cb1f255ad87666c690",
      "artifactSha256": "9b6ccd3692d8bcc52c79a0a8ad2df9bdc1bb1d842197fa01aa62b93cbd61bce2",
      "url": "/reference/source/forge-rs/crates/forge-provider-openai/src/model.rs.txt",
      "declarations": [
        {
          "name": "::OpenAiLanguageModel",
          "line": 76,
          "signature": "pub struct OpenAiLanguageModel {\n\n}",
          "documentation": "OpenAI language model implementing the Forge `LanguageModel` trait.\n\nProvides text generation and streaming via the OpenAI ChatCompletion API.\nHandles message translation, tool calling, structured output, and\nmodel-specific quirks.\n\n# ANVIL Spec \u00a76.1\n\nThis implementation satisfies the cognitive interface contract for the\n`openai` provider namespace.\n\n# Examples\n\n```no_run\nuse forge_provider_openai::{OpenAiLanguageModel, OpenAiConfig};\nuse forge_core::model::LanguageModel;\nuse forge_core::message::{ModelMessage, Role};\nuse forge_core::config::GenerateOptions;\n\n# async fn example() -> Result<(), Box<dyn std::error::Error>> {\nlet config = OpenAiConfig::builder(\"sk-your-key\").build();\nlet model = OpenAiLanguageModel::new(\"gpt-4o\".to_string(), config)?;\n\nassert_eq!(model.model_id(), \"gpt-4o\");\nassert_eq!(model.provider(), \"openai\");\nassert!(model.supports_tool_calling());\nassert!(model.supports_image_input()); // gpt-4o supports vision\n# Ok(())\n# }\n```"
        },
        {
          "name": "::OpenAiLanguageModel::new",
          "line": 112,
          "signature": "pub fn new(model_id: String, config: OpenAiConfig) -> ForgeResult<Self>;",
          "documentation": "Creates a new OpenAI language model instance.\n\n# Arguments\n\n* `model_id` - The OpenAI model identifier (e.g., \"gpt-4o\", \"o3-mini\").\n* `config` - The provider configuration with API key and settings.\n\n# Returns\n\nThe initialized model, ready for inference calls.\n\n# Errors\n\nReturns `ForgeError::MissingConfig` if the API key is empty.\n\n# Examples\n\n```no_run\nuse forge_provider_openai::{OpenAiLanguageModel, OpenAiConfig};\n\nlet config = OpenAiConfig::builder(\"sk-key\").build();\nlet model = OpenAiLanguageModel::new(\"gpt-4o\".to_string(), config);\nassert!(model.is_ok());\n```"
        }
      ]
    },
    {
      "path": "forge-rs/crates/forge-provider-openai/src/sse.rs",
      "sha256": "dbd9f3a1872382987a1db08da44f89e56a537d565890326b3ca418caded00993",
      "artifactSha256": "97d1299a13bb1aeea378c3d839593067246f9a533949a46feaad498e59e88580",
      "url": "/reference/source/forge-rs/crates/forge-provider-openai/src/sse.rs.txt",
      "declarations": [
        {
          "name": "::parse_sse_response",
          "line": 61,
          "signature": "pub fn parse_sse_response(body: &str) -> Result<Vec<ChatCompletionChunk>, OpenAiError>;",
          "documentation": "Parses a raw SSE response body into a vector of `ChatCompletionChunk`.\n\nProcesses each `data:` line, ignoring comment lines (starting with `:`)\nand blank lines. The stream terminates when `data: [DONE]` is encountered.\n\n# Arguments\n\n* `body` - The raw SSE response body as a string.\n\n# Returns\n\nA vector of parsed `ChatCompletionChunk` objects.\n\n# Errors\n\nReturns `OpenAiError::StreamError` if:\n- A `data:` line contains invalid JSON.\n- The response body is empty and contains no data lines.\n\n# Examples\n\n```\nuse forge_provider_openai::sse::parse_sse_response;\n\nlet body = \"data: {\\\"id\\\":\\\"abc\\\",\\\"choices\\\":[{\\\"index\\\":0,\\\"delta\\\":{\\\"content\\\":\\\"Hi\\\"},\\\"finish_reason\\\":null}]}\\n\\ndata: [DONE]\\n\\n\";\nlet chunks = parse_sse_response(body);\nassert!(chunks.is_ok());\n```"
        },
        {
          "name": "::DecoderState",
          "line": 113,
          "signature": "#[derive(Debug, Clone, Copy, PartialEq, Eq)]\npub enum DecoderState {\n    /// Stream is ongoing; more data can be fed.\n    Continue,\n    /// Terminal `[DONE]` sentinel observed; further bytes will be ignored.\n    Done,\n}",
          "documentation": "Outcome of feeding bytes into [`OpenAiSseDecoder`]."
        },
        {
          "name": "::OpenAiSseDecoder",
          "line": 139,
          "signature": "pub struct OpenAiSseDecoder {\n\n}",
          "documentation": "Stateful SSE decoder for incremental byte streams from OpenAI.\n\nBuffers partial events across `feed(&[u8])` calls and yields complete\n`ChatCompletionChunk` values via `drain()`. Tolerates byte-chunk\nboundaries that split events anywhere \u2014 the only producer guarantee is\nthat line terminators (`\\n` or `\\r\\n`) appear at byte boundaries where\nthe producer wrote them.\n\n# Examples\n\n```\nuse forge_provider_openai::sse::OpenAiSseDecoder;\n\nlet mut decoder = OpenAiSseDecoder::new();\ndecoder.feed(b\"data: {\\\"id\\\":\\\"x\\\",\\\"choices\\\":[]}\\n\\ndata: [DONE]\\n\\n\").unwrap();\nlet chunks = decoder.drain();\nassert_eq!(chunks.len(), 1);\nassert_eq!(chunks[0].id, \"x\");\n```"
        },
        {
          "name": "::OpenAiSseDecoder::new",
          "line": 150,
          "signature": "pub fn new() -> Self;",
          "documentation": "Creates a new, empty decoder."
        },
        {
          "name": "::OpenAiSseDecoder::feed",
          "line": 167,
          "signature": "pub fn feed(&mut self, bytes: &[u8]) -> Result<DecoderState, OpenAiError>;",
          "documentation": "Feeds raw bytes into the decoder. Any complete events that become\navailable are queued; call [`drain`](Self::drain) to take them.\nReturns `DecoderState::Done` once `[DONE]` has been observed.\n\n# Errors\n\nReturns `OpenAiError::StreamError` if a complete `data:` line's JSON\npayload fails to deserialize into [`ChatCompletionChunk`]. Partial\nevents (still waiting for more bytes) never error here."
        },
        {
          "name": "::OpenAiSseDecoder::drain",
          "line": 224,
          "signature": "pub fn drain(&mut self) -> Vec<ChatCompletionChunk>;",
          "documentation": "Drains all events ready to be consumed."
        },
        {
          "name": "::OpenAiSseDecoder::is_done",
          "line": 229,
          "signature": "pub fn is_done(&self) -> bool;",
          "documentation": "Whether the terminal `[DONE]` sentinel has been observed."
        },
        {
          "name": "::OpenAiSseDecoder::finish",
          "line": 239,
          "signature": "pub fn finish(&mut self) -> Result<Vec<ChatCompletionChunk>, OpenAiError>;",
          "documentation": "Signals end-of-stream, processing any leftover unterminated bytes as\na (best-effort) final line. Returns any remaining queued events.\n\nOpenAI streams normally end with `data: [DONE]\\n\\n`, but if the\nupstream connection drops without that, this method tries to parse\nany final partial line."
        }
      ]
    },
    {
      "path": "forge-rs/crates/forge-provider-openai/src/types.rs",
      "sha256": "00f18148d69dd6550005f21e4806e0b92248202be57b5527b41169f04029fd34",
      "artifactSha256": "df24f6dd175846563999e0e6ffe3066b752cfe285ed7b01891f7493e8d50ca17",
      "url": "/reference/source/forge-rs/crates/forge-provider-openai/src/types.rs.txt",
      "declarations": [
        {
          "name": "::ChatCompletionRequest",
          "line": 21,
          "signature": "#[derive(Debug, Clone, Serialize, Deserialize)]\npub struct ChatCompletionRequest {\n/// The model ID (e.g., \"gpt-4o\").\n\npub model: String,\n/// The conversation messages.\n\npub messages: Vec<ChatMessage>,\n/// Tool definitions available to the model.\n\n#[serde(skip_serializing_if = \"Option::is_none\")]\npub tools: Option<Vec<ApiToolDefinition>>,\n/// Sampling temperature (0.0 to 2.0).\n\n#[serde(skip_serializing_if = \"Option::is_none\")]\npub temperature: Option<f64>,\n/// Maximum tokens to generate.\n\n#[serde(skip_serializing_if = \"Option::is_none\")]\npub max_tokens: Option<u32>,\n/// Top-p (nucleus) sampling threshold.\n\n#[serde(skip_serializing_if = \"Option::is_none\")]\npub top_p: Option<f64>,\n/// Up to 4 stop sequences.\n\n#[serde(skip_serializing_if = \"Option::is_none\")]\npub stop: Option<Vec<String>>,\n/// Frequency penalty (-2.0 to 2.0).\n\n#[serde(skip_serializing_if = \"Option::is_none\")]\npub frequency_penalty: Option<f64>,\n/// Presence penalty (-2.0 to 2.0).\n\n#[serde(skip_serializing_if = \"Option::is_none\")]\npub presence_penalty: Option<f64>,\n/// Seed for deterministic generation.\n\n#[serde(skip_serializing_if = \"Option::is_none\")]\npub seed: Option<u64>,\n/// Response format for structured output.\n\n#[serde(skip_serializing_if = \"Option::is_none\")]\npub response_format: Option<ResponseFormat>,\n/// Whether to stream the response.\n\n#[serde(skip_serializing_if = \"Option::is_none\")]\npub stream: Option<bool>,\n/// Stream options (e.g., include usage in stream).\n\n#[serde(skip_serializing_if = \"Option::is_none\")]\npub stream_options: Option<StreamOptions>\n}",
          "documentation": "A ChatCompletion API request body.\n\nSee <https://platform.openai.com/docs/api-reference/chat/create>."
        },
        {
          "name": "::StreamOptions",
          "line": 75,
          "signature": "#[derive(Debug, Clone, Serialize, Deserialize)]\npub struct StreamOptions {\n/// Whether to include usage statistics in the final stream chunk.\n\n#[serde(skip_serializing_if = \"Option::is_none\")]\npub include_usage: Option<bool>\n}",
          "documentation": "Stream options for controlling streaming behavior."
        },
        {
          "name": "::ChatMessage",
          "line": 88,
          "signature": "#[derive(Debug, Clone, Serialize, Deserialize)]\npub struct ChatMessage {\n/// The role: \"system\", \"user\", \"assistant\", or \"tool\".\n\npub role: String,\n/// The message content (text or multi-part).\n\n#[serde(skip_serializing_if = \"Option::is_none\")]\npub content: Option<ChatContent>,\n/// Tool calls made by the assistant.\n\n#[serde(skip_serializing_if = \"Option::is_none\")]\npub tool_calls: Option<Vec<ApiToolCall>>,\n/// The tool call ID this message responds to (for tool role).\n\n#[serde(skip_serializing_if = \"Option::is_none\")]\npub tool_call_id: Option<String>,\n/// The tool name (for tool role messages).\n\n#[serde(skip_serializing_if = \"Option::is_none\")]\npub name: Option<String>\n}",
          "documentation": "A message in the OpenAI ChatCompletion format.\n\nThe structure varies by role:\n- **system/user**: `content` is a string or content array\n- **assistant**: may have `content` and/or `tool_calls`\n- **tool**: has `content` (result) and `tool_call_id`"
        },
        {
          "name": "::ChatContent",
          "line": 115,
          "signature": "#[derive(Debug, Clone, Serialize, Deserialize)]\n#[serde(untagged)]\npub enum ChatContent {\n    /// Plain text content.\n    Text(String),\n    /// Array of content parts (text and/or images).\n    Parts(Vec<ContentPart>),\n}",
          "documentation": "Message content \u2014 either a plain string or an array of content parts.\n\nOpenAI's API accepts both formats. Text-only messages use the string\nform; multi-modal messages (with images) use the array form."
        },
        {
          "name": "::ContentPart",
          "line": 125,
          "signature": "#[derive(Debug, Clone, Serialize, Deserialize)]\n#[serde(tag = \"type\", rename_all = \"snake_case\")]\npub enum ContentPart {\n    /// A text content part.\n    Text {\n        /// The text content.\n        text: String,\n    },\n    /// An image URL content part.\n    ImageUrl {\n        /// The image URL object.\n        image_url: ImageUrlObject,\n    },\n}",
          "documentation": "A content part within a multi-part message."
        },
        {
          "name": "::ImageUrlObject",
          "line": 140,
          "signature": "#[derive(Debug, Clone, Serialize, Deserialize)]\npub struct ImageUrlObject {\n/// The image URL. For base64, use `data:<media_type>;base64,<data>`.\n\npub url: String\n}",
          "documentation": "An image URL reference within a content part."
        },
        {
          "name": "::ApiToolCall",
          "line": 147,
          "signature": "#[derive(Debug, Clone, Serialize, Deserialize)]\npub struct ApiToolCall {\n/// Unique identifier for this tool call.\n\npub id: String,\n/// The type of tool call \u2014 always \"function\" for now.\n\n#[serde(rename = \"type\")]\npub call_type: String,\n/// The function being called.\n\npub function: FunctionCall\n}",
          "documentation": "A tool call in the assistant's response."
        },
        {
          "name": "::FunctionCall",
          "line": 161,
          "signature": "#[derive(Debug, Clone, Serialize, Deserialize)]\npub struct FunctionCall {\n/// The function name.\n\npub name: String,\n/// The function arguments as a JSON string.\n\npub arguments: String\n}",
          "documentation": "A function call within a tool call."
        },
        {
          "name": "::ApiToolDefinition",
          "line": 171,
          "signature": "#[derive(Debug, Clone, Serialize, Deserialize)]\npub struct ApiToolDefinition {\n/// The type \u2014 always \"function\".\n\n#[serde(rename = \"type\")]\npub tool_type: String,\n/// The function definition.\n\npub function: FunctionDef\n}",
          "documentation": "A tool definition in the OpenAI format."
        },
        {
          "name": "::FunctionDef",
          "line": 182,
          "signature": "#[derive(Debug, Clone, Serialize, Deserialize)]\npub struct FunctionDef {\n/// The function name.\n\npub name: String,\n/// A human-readable description of what the function does.\n\n#[serde(skip_serializing_if = \"Option::is_none\")]\npub description: Option<String>,\n/// JSON Schema for the function's parameters.\n\n#[serde(skip_serializing_if = \"Option::is_none\")]\npub parameters: Option<serde_json::Value>\n}",
          "documentation": "A function definition within a tool definition."
        },
        {
          "name": "::ResponseFormat",
          "line": 197,
          "signature": "#[derive(Debug, Clone, Serialize, Deserialize)]\npub struct ResponseFormat {\n/// The format type: \"text\", \"json_object\", or \"json_schema\".\n\n#[serde(rename = \"type\")]\npub format_type: String,\n/// JSON schema definition (only for `json_schema` type).\n\n#[serde(skip_serializing_if = \"Option::is_none\")]\npub json_schema: Option<JsonSchemaFormat>\n}",
          "documentation": "Response format for structured output."
        },
        {
          "name": "::JsonSchemaFormat",
          "line": 209,
          "signature": "#[derive(Debug, Clone, Serialize, Deserialize)]\npub struct JsonSchemaFormat {\n/// Name for the schema (required by OpenAI).\n\npub name: String,\n/// The JSON Schema object.\n\npub schema: serde_json::Value,\n/// Whether to enforce strict schema adherence.\n\n#[serde(skip_serializing_if = \"Option::is_none\")]\npub strict: Option<bool>\n}",
          "documentation": "A JSON schema format specification for structured output."
        },
        {
          "name": "::ChatCompletionResponse",
          "line": 229,
          "signature": "#[derive(Debug, Clone, Serialize, Deserialize)]\npub struct ChatCompletionResponse {\n/// Unique response identifier.\n\npub id: String,\n/// The list of completion choices.\n\npub choices: Vec<ChatCompletionChoice>,\n/// Token usage statistics.\n\n#[serde(skip_serializing_if = \"Option::is_none\")]\npub usage: Option<ApiUsage>,\n/// The model that generated the response.\n\npub model: String\n}",
          "documentation": "A ChatCompletion API response.\n\nSee <https://platform.openai.com/docs/api-reference/chat/object>."
        },
        {
          "name": "::ChatCompletionChoice",
          "line": 246,
          "signature": "#[derive(Debug, Clone, Serialize, Deserialize)]\npub struct ChatCompletionChoice {\n/// The choice index.\n\npub index: u32,\n/// The generated message.\n\npub message: ChatMessage,\n/// Why generation stopped.\n\npub finish_reason: Option<String>\n}",
          "documentation": "A single completion choice."
        },
        {
          "name": "::ApiUsage",
          "line": 259,
          "signature": "#[derive(Debug, Clone, Serialize, Deserialize)]\npub struct ApiUsage {\n/// Tokens consumed by the prompt.\n\npub prompt_tokens: u64,\n/// Tokens generated in the completion.\n\npub completion_tokens: u64,\n/// Total tokens (prompt + completion).\n\npub total_tokens: u64\n}",
          "documentation": "Token usage statistics from the OpenAI API."
        },
        {
          "name": "::ChatCompletionChunk",
          "line": 278,
          "signature": "#[derive(Debug, Clone, Serialize, Deserialize)]\npub struct ChatCompletionChunk {\n/// Unique response identifier (same across all chunks).\n\npub id: String,\n/// The list of chunk choices.\n\npub choices: Vec<ChunkChoice>,\n/// Usage statistics (only present in the final chunk when `stream_options.include_usage` is true).\n\n#[serde(skip_serializing_if = \"Option::is_none\")]\npub usage: Option<ApiUsage>\n}",
          "documentation": "A streaming chunk from the ChatCompletion API.\n\nSee <https://platform.openai.com/docs/api-reference/chat/streaming>."
        },
        {
          "name": "::ChunkChoice",
          "line": 292,
          "signature": "#[derive(Debug, Clone, Serialize, Deserialize)]\npub struct ChunkChoice {\n/// The choice index.\n\npub index: u32,\n/// The content delta for this chunk.\n\npub delta: ChunkDelta,\n/// Why generation stopped (present in the final chunk).\n\npub finish_reason: Option<String>\n}",
          "documentation": "A single choice within a streaming chunk."
        },
        {
          "name": "::ChunkDelta",
          "line": 305,
          "signature": "#[derive(Debug, Clone, Serialize, Deserialize)]\npub struct ChunkDelta {\n/// The role (typically only in the first chunk).\n\n#[serde(skip_serializing_if = \"Option::is_none\")]\npub role: Option<String>,\n/// Text content delta.\n\n#[serde(skip_serializing_if = \"Option::is_none\")]\npub content: Option<String>,\n/// Tool call deltas.\n\n#[serde(skip_serializing_if = \"Option::is_none\")]\npub tool_calls: Option<Vec<ChunkToolCall>>\n}",
          "documentation": "The delta content within a streaming chunk."
        },
        {
          "name": "::ChunkToolCall",
          "line": 321,
          "signature": "#[derive(Debug, Clone, Serialize, Deserialize)]\npub struct ChunkToolCall {\n/// The tool call index (for correlating deltas).\n\npub index: u32,\n/// The tool call ID (may only be present in the first delta).\n\n#[serde(skip_serializing_if = \"Option::is_none\")]\npub id: Option<String>,\n/// The tool call type (may only be present in the first delta).\n\n#[serde(rename = \"type\")]\n#[serde(skip_serializing_if = \"Option::is_none\")]\npub call_type: Option<String>,\n/// The function call delta.\n\n#[serde(skip_serializing_if = \"Option::is_none\")]\npub function: Option<ChunkFunctionCall>\n}",
          "documentation": "A tool call delta within a streaming chunk."
        },
        {
          "name": "::ChunkFunctionCall",
          "line": 341,
          "signature": "#[derive(Debug, Clone, Serialize, Deserialize)]\npub struct ChunkFunctionCall {\n/// The function name (may only be present in the first delta).\n\n#[serde(skip_serializing_if = \"Option::is_none\")]\npub name: Option<String>,\n/// Partial function arguments (streamed incrementally).\n\n#[serde(skip_serializing_if = \"Option::is_none\")]\npub arguments: Option<String>\n}",
          "documentation": "A function call delta within a streaming tool call chunk."
        },
        {
          "name": "::ApiErrorResponse",
          "line": 357,
          "signature": "#[derive(Debug, Clone, Serialize, Deserialize)]\npub struct ApiErrorResponse {\n/// The error detail object.\n\npub error: ApiErrorDetail\n}",
          "documentation": "An error response from the OpenAI API."
        },
        {
          "name": "::ApiErrorDetail",
          "line": 364,
          "signature": "#[derive(Debug, Clone, Serialize, Deserialize)]\npub struct ApiErrorDetail {\n/// The error message.\n\npub message: String,\n/// The error type (e.g., \"invalid_request_error\").\n\n#[serde(rename = \"type\")]\n#[serde(skip_serializing_if = \"Option::is_none\")]\npub error_type: Option<String>,\n/// The parameter that caused the error.\n\n#[serde(skip_serializing_if = \"Option::is_none\")]\npub param: Option<String>,\n/// The error code (e.g., \"model_not_found\").\n\n#[serde(skip_serializing_if = \"Option::is_none\")]\npub code: Option<String>\n}",
          "documentation": "Error detail from the OpenAI API."
        }
      ]
    }
  ]
}
