Prefer CohereConfig.fromValues over the companion apply; it resolves contextWindow and reserveCompletion automatically from the model name, and normalises the base URL to Cohere's OpenAI-compatibility endpoint.
This was in llm4s-core until Cohere moved onto llm4s-openai-compatible's shared client (#1132); its package is unchanged. The client now speaks Cohere's Compatibility API (/compatibility/v1/chat/completions) rather than the native v2 /v2/chat, which is what gives it streaming, tool calling and structured output (#925).
The constructor is private: build one with the companion apply, whose defaults cover every field after model, and adjust it with the with* setters. Java and Kotlin, which cannot see Scala default arguments, use CohereConfig.apply(apiKey, model) and the setters, so adding a field never breaks them (#2264).
Value parameters
apiKey
Cohere API key; redacted in toString.
apiKeyProvider
asked for the key on every request instead of sending apiKey, so a rotated key is used without rebuilding the client (#2477): a section's apiKeyFile sets one
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.
The same config, its client asking provider for the key on each request, so a rotated key is used without rebuilding the client.
The same config, its client asking provider for the key on each request, so a rotated key is used without rebuilding the client.
Attributes
Returns
the config, or a org.llm4s.error.ConfigurationError from a config that cannot take one: a provider that authenticates without an API key (Ollama, Bedrock, Vertex AI), or one whose client reads the key once. ProviderConfig.noApiKeyProvider builds that error. It is never ignored.
The same config with the given proxy and TLS settings.
The same config with the given proxy and TLS settings.
The loader calls this on every config a descriptor builds, as it does withTimeouts, so a descriptor does not read the http block itself. There is no default, so a configured proxy is never bypassed by omission. A config whose provider makes no HTTP call returns itself and keeps network at the default; the loader then refuses a section with an http block of its own (the process-wide llm4s.http has nothing to route there, so it is not an error).
The loader calls this on every config a descriptor builds, passing the section's timeouts block, so a descriptor does not read the block itself. There is no default: a config states what it does with them. One whose provider makes no timed call (a model run in-process) returns itself and keeps timeouts at the default, and the loader then refuses a section that sets timeouts rather than dropping them.