createOpenAIModelProvider
Purpose and behavior
Section titled “Purpose and behavior”Create a reusable provider for an OpenAI-compatible service over Chat Completions (default) or Responses, with tool calls, reasoning effort and streaming. Invalid options fail with code configuration. Each request is sent once, with no retry or protocol fallback.
Complete example and detailed rules.
Parameters and properties
Section titled “Parameters and properties”optionsRequiredOpenAIModelProviderOptionsBase URL, protocol, API key and request bounds. Unknown options fail with code configuration.options.apiOptional"chat-completions" | "responses" | undefinedHTTP protocol: chat-completions by default, or responses. No automatic protocol fallback.options.baseUrlRequiredstringAbsolute HTTP(S) base URL including its version prefix, such as https://api.openai.com/v1; chat/completions or responses is appended. Credentials, query or fragment fail with code configuration, and redirects are refused.options.apiKeyRequiredstring | falseExplicit bearer API key, or false for an unauthenticated endpoint. No environment variable or account login is read automatically.options.timeoutMsOptionalnumber | undefinedRequest deadline in milliseconds, default 120000, at most 2147483647. While streaming it restarts on each received chunk; expiry rejects with code timeout.options.maxResponseBytesOptionalnumber | undefinedMaximum response body in bytes after decompression, default 8388608 (8 MiB); a streamed response counts all its chunks. A larger response fails with code response.