Configuration for the generic openai-compatible provider: any endpoint that speaks the OpenAI /chat/completions API, such as Groq, Together, Fireworks, a vLLM, LM Studio or llama.cpp server, or an internal gateway.
Nothing is known about the model up front, so the context window and completion reserve come from config, defaulting to the conservative OpenAICompatibleConfig.DEFAULT_CONTEXT_WINDOW and OpenAICompatibleConfig.DEFAULT_RESERVE_COMPLETION. Set them to the model's real limits so context compression neither truncates early nor overflows.
Prefer OpenAICompatibleConfig.fromValues, which validates the values. The constructor is private: build one with the companion apply, whose defaults cover every field after baseUrl, and adjust it with the with* setters. Java and Kotlin, which cannot see Scala default arguments, use OpenAICompatibleConfig.apply(model, baseUrl) and the setters, so adding a field never breaks them.
Value parameters
- apiKey
-
sent as
Authorization: Bearer <key>;Nonesends noAuthorizationheader, for servers that need none. Redacted intoString. - baseUrl
-
API base URL; requests go to
<baseUrl>/chat/completions. - contextWindow
-
the model's total token capacity (prompt + completion).
- headers
-
extra headers sent on every request, e.g. a gateway's own auth header. Values are redacted in
toString. - model
-
model identifier sent in every request.
- reserveCompletion
-
tokens held back from prompt history for the completion.
- streamUsage
-
whether a streaming request asks for token usage with
"stream_options": {"include_usage": true}. Servers that follow OpenAI (vLLM, Ollama's/v1) stream no usage without it; turn it off for an endpoint that rejects the field. A named section sets it with thestreamUsagekey. - timeouts
-
how long a request and a stream may take: the section's
timeoutsblock. An absent value keeps the client's own default (ProviderTimeouts) - tokenExchange
-
workload-identity auth: the identity token is exchanged here for the bearer token, which replaces
apiKey; never set together withapiKeyor anAuthorizationentry inheaders, and itstokenUrlandbaseUrlmust behttps(plainhttponly to a loopback host). The exchanged token goes tobaseUrl, a host the user chooses, so no host is allow-listed here. OpenAICompatibleConfig.fromValues checks these, andOpenAICompatibleClientrefuses a config built any other way that breaks them.
Attributes
- Companion
- object
- Graph
-
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait ProviderConfigclass Objecttrait Matchableclass Any