Skip to navigation

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 example uses cohere/command-a-reasoning-08-2025, which is marked Live in the model catalog. Connect your Cohere credentials in Respan before making requests.

1

Install packages

pip install openai
2

Set environment variables

export RESPAN_API_KEY="YOUR_RESPAN_API_KEY"

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

3

Point to the Respan gateway

import os
from openai import OpenAI
client = OpenAI(
api_key=os.getenv("RESPAN_API_KEY"),
base_url="https://api.respan.ai/api",
)
response = client.chat.completions.create(
model="cohere/command-a-reasoning-08-2025",
messages=[{"role": "user", "content": "Say hello in three languages."}],
)
print(response.choices[0].message.content)

Switch models

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

response = client.chat.completions.create(model="cohere/command-a-reasoning-08-2025", messages=messages)
response = client.chat.completions.create(model="openai/gpt-6-sol", messages=messages)

See the full model list.