Skip to main content

Overview

Bifrost provides Cohere v2 API compatibility through protocol adaptation. The integration accepts Cohere’s native request bodies on /cohere, converts them into Bifrost’s internal format, and rebuilds Cohere’s native response envelopes on the way out. Point the official Cohere SDK at Bifrost and your existing code keeps working, with governance, load balancing, semantic caching, logging and multi-provider routing added underneath. Endpoint: /cohere

Supported routes

Each route works against Cohere models by default and against any other provider when the model is prefixed with the provider name (see Provider/Model Usage).
The Cohere SDKs append the version path themselves (/v2/chat, /v2/embed, /v2/rerank, /v1/tokenize), so the base URL is the bare http://localhost:8080/cohere, without a version suffix.

Setup


Provider/Model Usage Examples

Use multiple providers through the same Cohere SDK format by prefixing model names with the provider. Bifrost converts the Cohere request into the target provider’s format and converts the result back into Cohere’s response shape.

Chat

/cohere/v2/chat accepts the full Cohere v2 chat body: messages, tools, response_format, thinking, max_tokens, temperature, p, k, stop_sequences and the rest. Bifrost maps these onto each provider’s own parameters. See the Cohere provider page for the exact parameter mapping.

Streaming

Streaming on /cohere/v2/chat returns Cohere’s native event stream only when both hold: the model is served by Cohere, and raw responses are enabled for the Cohere provider. Bifrost replays the raw Cohere events rather than rebuilding them, so without raw responses the stream is emitted in Bifrost’s OpenAI-style chunk format even for Cohere models, and the Cohere SDK’s stream parser will not understand it.Enable raw responses either in the provider config or per request:
For a provider/model that routes elsewhere, the stream is always emitted in Bifrost’s chunk format. Use non-streaming calls for cross-provider chat through this route, or use the OpenAI SDK integration for cross-provider streaming. See Request Options for the full list of x-bf-* headers.

Embeddings

/cohere/v2/embed accepts all three of Cohere’s input fields and returns Cohere’s native envelope (embeddings, response_type, meta.billed_units) for every provider. input_type, embedding_types, truncate and output_dimension are forwarded. When embedding_types lists several formats, each comes back under its own key in embeddings (float, int8, uint8, binary, ubinary, base64).
Images must be inline data URIs; Cohere does not fetch remote URLs. Which modalities a non-Cohere model accepts through this route follows the model, not the SDK: see the multimodal embeddings support matrix.

Rerank

/cohere/v2/rerank accepts string documents or object documents, top_n and max_tokens_per_doc, and returns Cohere’s results[] with index and relevance_score. Map index back onto the documents you sent to recover the text. Cross-provider rerank (for example a vLLM or custom OpenAI-compatible reranker) is converted into the same shape.
See the Reranking guide for the provider-neutral /v1/rerank endpoint and the models that support it.

Tokenize

/cohere/v1/tokenize takes model and text and maps to Bifrost’s count-tokens operation. Cohere’s native response (tokens, token_strings, meta) is returned only when the model is served by Cohere and raw responses are enabled (send_back_raw_response on the provider, or the x-bf-send-back-raw-response: true header, as in the streaming note above). In every other case, including Cohere models without raw responses, the response is Bifrost’s count-tokens shape, which the SDK’s typed tokenize() client does not parse.

Adding Custom Headers

Pass custom headers required by Bifrost plugins (like governance, telemetry, etc.):

Supported Features

The Cohere integration supports the four routes above for any model Bifrost can reach. Operations the Cohere API does not expose (text completions, image generation, speech, transcription, files, batch) are not available on /cohere; use the OpenAI SDK integration or the native /v1 endpoints for those. Known differences from calling Cohere directly:
  • Streaming and tokenize need raw responses. Native Cohere stream events and the native tokenize response are passed through only when send_back_raw_response is enabled for the Cohere provider (or the x-bf-send-back-raw-response header is set). Otherwise both fall back to Bifrost’s own shape, even for Cohere models.
  • Cross-provider streaming on /v2/chat always emits Bifrost’s chunk format rather than Cohere’s event stream, regardless of the raw-response setting.
  • Cross-provider tokenize always returns Bifrost’s count-tokens response rather than Cohere’s tokens / token_strings shape.
  • Native passthrough: with raw responses enabled and the model served by Cohere, chat, embed, rerank and tokenize responses are returned exactly as Cohere sent them. Without raw responses, non-streaming chat, embed and rerank are rebuilt from Bifrost’s format into Cohere’s shape, so they still parse in the SDK.

Next Steps