Constructs an OpenAIConfig, resolving contextWindow and reserveCompletion from the model name automatically.
Constructs an OpenAIConfig, resolving contextWindow and reserveCompletion from the model name automatically.
The resolver first consults a bundled model-metadata catalogue; if the model is not listed there it falls back to name-pattern matching before defaulting to 8192 tokens. Prefer this factory over the primary constructor so that new models receive correct context-window values without manual lookup.
Value parameters
apiKey
OpenAI API key; must be non-empty.
baseUrl
API base URL; must be non-empty. Pass a URL containing "openrouter.ai" to route through OpenRouter.