Skip to content

cohere://

Cohere — Command R/R+ family chat models via the Cohere v2 Chat API. Native shape, not OpenAI-compatible (the response uses a message.content[] array of typed blocks). Cohere also offers strong embeddings and rerankers, but this scheme covers chat only.

URI shape

cohere://chat?model=<id>&apiKey=<key>&temperature=<float>&maxTokens=<int>&baseURL=<url>

Parameters

Param Type Default Producer/Consumer/Both Description
model string command-r-plus Producer Cohere model id. Common: command-r-plus, command-r, command, command-light.
apiKey string (from constructor) Producer Cohere API key. Sent as Authorization: Bearer <key>.
baseURL string https://api.cohere.com/v2 Producer Override for proxies or future API versions.
temperature float 0.7 Producer Sampling temperature.
maxTokens int 4096 Producer Output cap.

Operation defaults to chat; nothing else is supported. Producer-only.

Headers

Reads:

Header Effect
systemPrompt Prepended as a role: system message.

Sets:

Header Description
cohere.model Model id used.
cohere.finishReason Cohere stop reason (COMPLETE, MAX_TOKENS, ERROR_LIMIT, ERROR_TOXIC, etc.).
cohere.usage.inputTokens / outputTokens / totalTokens From usage block.

Examples

- id: cohere-chat
  from: direct://chat
  steps:
    - to: cohere://chat?model=command-r-plus&apiKey=${COHERE_API_KEY}

Tighter cap for short classification answers:

- setHeader:
    name: systemPrompt
    starlang: "%sl 2.0\noutput text/plain\n---\n\"Reply with only YES or NO.\""
- to: cohere://chat?model=command-r&apiKey=${COHERE_API_KEY}&maxTokens=4&temperature=0

Behavior notes

  • Response is an array of typed content blocks ([{type: "text", text: "..."}]). The component picks the first block with type either "text" or empty and uses its text. Other block types (e.g. tool calls) are ignored on this raw path.
  • No tool-use, no embeddings, no rerank on this scheme — use the agent component for first-class Cohere tool calling, or the rag postprocessors for Cohere rerank.
  • Endpoint: POST {baseURL}/chat.
  • 120s timeout. No retries.

Source

  • pkg/component/cohere/cohere.go
  • pkg/component/cohere/cohere_test.go

See also