Cohere (gateway)

Route Cohere chat through the Respan gateway with the OpenAI-compatible API after you select a current Cohere model that is configured in Respan.

Setup

The previous legacy Cohere command-model examples did not pass live verification because they are no longer available through the tested gateway catalog. Use the current model ID shown in your Respan model list.

1

Install packages

$pip install openai
2

Set environment variables

$export RESPAN_API_KEY="YOUR_RESPAN_API_KEY"

No CO_API_KEY is needed in your application when the Cohere model is already configured in Respan.

3

Point to the Respan gateway

1import os
2from openai import OpenAI
3
4client = OpenAI(
5 api_key=os.getenv("RESPAN_API_KEY"),
6 base_url="https://api.respan.ai/api",
7)
8
9response = client.chat.completions.create(
10 model="YOUR_COHERE_MODEL_ID",
11 messages=[{"role": "user", "content": "Say hello in three languages."}],
12)
13print(response.choices[0].message.content)

Switch models

Change the model parameter to use Cohere or any other gateway-supported model through the same gateway.

1response = client.chat.completions.create(model="YOUR_COHERE_MODEL_ID", messages=messages)
2response = client.chat.completions.create(model="gpt-5.5", messages=messages)

See the full model list.