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
- Python
- JavaScript
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.- Python
- JavaScript
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
- Python
- JavaScript
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).
- Python
- JavaScript
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.
- Python
- JavaScript
/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.):- Python
- JavaScript
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_responseis enabled for the Cohere provider (or thex-bf-send-back-raw-responseheader is set). Otherwise both fall back to Bifrost’s own shape, even for Cohere models. - Cross-provider streaming on
/v2/chatalways 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_stringsshape. - 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
- OpenAI SDK - GPT integration patterns
- Anthropic SDK - Claude integration patterns
- Google GenAI SDK - Gemini integration patterns
- Cohere Provider - Parameter mapping and provider configuration
- Multimodal Embeddings - Image, audio, video and PDF embeddings
- Configuration - Bifrost setup and configuration

