Skip to main content

Overview

Cohere has a different API structure from OpenAI’s format. Bifrost performs conversions including:
  • Parameter renaming - e.g., max_completion_tokensmax_tokens, top_pp, stopstop_sequences
  • Message content conversion - String and content block formats handled
  • Tool conversion - Tool definitions and tool choice mapped to Cohere format
  • Thinking/Reasoning transformation - reasoning parameters mapped to Cohere’s thinking structure
  • Response format conversion - JSON schema handling adapted to Cohere’s format

Supported Operations

Unsupported Operations (❌): Text Completions, Image Generation, Speech, Transcriptions, Files, and Batch are not supported by the upstream Cohere API. These return UnsupportedOperationError.

Setup & Configuration

Configure Cohere as a provider.
Cohere provider dashboard
  1. Navigate to Models > Model Providers. Look for Cohere under Configured Providers. If it is missing, click on Add New Provider and select Cohere.
  2. Click Add Key or edit an existing key.
  3. Set a name for your key.
  4. Paste your API key directly or use an environment variable (for example, env.COHERE_API_KEY).
  5. Set Allowed Models to All Models (default) or the specific model allowlist you want this key to serve.
  6. Save the provider configuration.

1. Chat Completions

Request Parameters

Parameter Mapping

Dropped Parameters

The following parameters are silently ignored: logit_bias, logprobs, top_logprobs, seed, parallel_tool_calls, service_tier

Extra Parameters

Use extra_params (SDK) or pass directly in request body (Gateway) for Cohere-specific fields:

Reasoning / Thinking

Documentation: See Bifrost Reasoning Reference

Parameter Mapping

  • reasoning.effortthinking.type (mapped to "enabled" or "disabled")
  • reasoning.max_tokensthinking.token_budget (token budget for thinking)

Critical Constraints

  • Minimum budget: 1 token required; requests with 0 tokens will be converted to disabled
  • Dynamic budget: -1 is converted to 1 automatically

Example

Message Conversion

Content Handling

  • String content: Messages can have simple string content
  • Content blocks: Messages can have arrays of content blocks (text, images, thinking)
  • Image conversion: image_url blocks with URL are supported
  • Tool calls: Converted from message assistant tool calls to Cohere format
  • Tool messages: Tool call results are passed with tool_call_id

Tool Conversion

Tool definitions are adapted to Cohere format with the following mappings:
  • Function namename (unchanged)
  • Function parametersparameters (flexible JSON format)
  • Strict mode (strict: true) is silently dropped (not supported)
Tool choice mapping:
  • "none""NONE"
  • "auto" or "required""REQUIRED" or "AUTO"
  • Specific tool selection → "REQUIRED" (Cohere uses function-level selection)

Response Format

Supported formats:
  • text - Plain text response
  • json_object - Structured JSON response
  • json_schema - JSON with schema validation (converted to json_object)
Schema is passed through response_format.json_schema field.

Response Conversion

Field Mapping

  • finish_reason: COMPLETE / STOP_SEQUENCEstop, MAX_TOKENSlength, TOOL_CALLtool_calls
  • input_tokensprompt_tokens | output_tokenscompletion_tokens
  • cached_tokensprompt_tokens_details.cached_tokens (if present)
  • Tool call arguments converted from string → string (no conversion needed, Cohere uses string format)

Streaming

Event sequence: message-startcontent-startcontent-deltacontent-endmessage-end Delta types:
  • content-delta with text → message content
  • content-delta with thinking → reasoning text
  • tool-call-start/delta/end → tool call events
  • tool-plan-delta → tool planning output

Caveats

Severity: Low Behavior: reasoning.max_tokens must be >= 1 Impact: Very low impact, conversion happens automatically Code: chat.go:104-130
Severity: Low Behavior: top_p parameter renamed to p Impact: Parameter name changes internally Code: chat.go:99
Severity: Low Behavior: strict: true in tool definitions silently dropped Impact: No schema validation enforcement Code: chat.go:168-185
Severity: Low Behavior: Tool arguments are already strings, no JSON serialization needed Impact: Minimal - Cohere v2 API expects string format Code: chat.go:70-78

2. Responses API

The Responses API uses the same underlying /v2/chat endpoint but converts between OpenAI’s Responses format and Cohere’s format.

Request Parameters

Parameter Mapping

Extra Parameters

Use extra_params (SDK) or pass directly in request body (Gateway):

Input & Instructions

  • Input: String converted to user message or array converted to messages
  • Instructions: Becomes system message (prepended to messages)

Tool Support

Supported types: function Tool conversions same as Chat Completions.

Response Conversion

  • textmessage | tool_usefunction_call
  • input_tokens / output_tokens preserved
  • Token details with cached tokens support

Streaming

Event sequence: message-startcontent-startcontent-deltacontent-endmessage-end Special handling:
  • Tool call arguments accumulated across chunks
  • Synthetic output_item.added events emitted for text/reasoning
  • Stable item IDs generated as msg_{messageID}_item_{outputIndex}

3. Embeddings

Request Parameters

Parameter Mapping

Extra Parameters

Use extra_params for Cohere-specific embedding options:

Critical Notes

  • Input Type Required: Cohere v3+ models require input_type parameter (defaults to "search_document")
  • Embedding Types: Specify which embedding types to return (e.g., "float", "int8")

Response Conversion

  • embeddings.floatdata[].embedding
  • meta.tokens → usage information
  • Multiple embedding types handled

4. List Models

Request: GET /v1/models?page_size={defaultPageSize} Field mapping: Model data converted to standard format Pagination: Cursor-based with next_page_token Note: endpoint and default_only filters available via extra_params