case class OpenAIConfig(apiKey: String, model: String, organization: Option[String], baseUrl: String, contextWindow: Int, reserveCompletion: Int) extends ProviderConfig
Configuration for the OpenAI API and providers that implement the OpenAI-compatible REST interface.
baseUrl governs which backend is contacted: "https://api.openai.com/v1" reaches OpenAI directly, while a URL containing "openrouter.ai" causes org.llm4s.llmconnect.LLMConnect to route to OpenRouter. Azure OpenAI uses AzureConfig, not this class.
Prefer OpenAIConfig.fromValues over the primary constructor; it resolves contextWindow and reserveCompletion from the model name automatically.
The endpoint this config will contact, when it is known statically.
The endpoint this config will contact, when it is known statically.
Used by policy checks and diagnostics that need to know where traffic will go without knowing which provider it belongs to. None means the config carries no single URL — not that it makes no network calls.
openai, or openrouter when baseUrl points at OpenRouter.
openai, or openrouter when baseUrl points at OpenRouter.
OpenRouter reuses this config but has its own client, and the base URL is the only thing distinguishing the two. Deriving the id here keeps that knowledge with the config rather than in a special case inside org.llm4s.llmconnect.LLMConnect, which is how routing worked before the provider registry (#1131).