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.
Value parameters
- apiKey
-
OpenAI API key; redacted in
toString. - baseUrl
-
API base URL; determines provider routing in org.llm4s.llmconnect.LLMConnect.
- contextWindow
-
Model's total token capacity (prompt + completion combined).
- model
-
Model identifier, e.g.
"gpt-4o". - organization
-
Optional OpenAI organisation ID.
- reserveCompletion
-
Tokens held back from prompt history for the completion.
Attributes
- Companion
- object
- Graph
-
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait ProviderConfigclass Objecttrait Matchableclass Any