CohereConfig

org.llm4s.llmconnect.config.CohereConfig
See theCohereConfig companion object
@Experimental
case class CohereConfig(apiKey: String, model: String, baseUrl: String, contextWindow: Int, reserveCompletion: Int, timeouts: ProviderTimeouts) extends ProviderConfig

Configuration for the Cohere API.

Prefer CohereConfig.fromValues over the primary constructor; 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).

Value parameters

apiKey

Cohere API key; redacted in toString.

baseUrl

The Compatibility API base; defaults to CohereConfig.DEFAULT_BASE_URL. Requests go to <baseUrl>/chat/completions. A native API root such as https://api.cohere.com is accepted and mapped - see CohereConfig.compatibilityBaseUrl.

contextWindow

Model's total token capacity (prompt + completion combined).

model

Model identifier, e.g. "command-a-03-2025".

reserveCompletion

Tokens held back from prompt history for the completion.

timeouts

how long a request and a stream may take: the section's timeouts block. An absent value keeps the client's own default (ProviderTimeouts)

Attributes

Companion
object
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

override def endpointUrl: Option[String]

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.

Attributes

Definition Classes
override def toString: String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns

a string representation of the object.

Definition Classes
Any
override def withModel(model: String): CohereConfig

The same provider and credentials, pointed at a different model.

The same provider and credentials, pointed at a different model.

Attributes

Definition Classes
override def withTimeouts(timeouts: ProviderTimeouts): CohereConfig

The same config with the given timeouts.

The same config with the given timeouts.

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. The default returns this: a config that does not carry timeouts, such as one supplied by another module, ignores them. A config that does overrides this with its own return type.

Attributes

Definition Classes

Inherited methods

def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product

Concrete fields

override val providerId: ProviderId

Canonical id of the provider this config addresses, e.g. ProviderId("openai").

Canonical id of the provider this config addresses, e.g. ProviderId("openai").

Attributes