Skip to content

Document how to use Cohere models through the OpenAI provider. #105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions docs/user-guide/concepts/model-providers/cohere.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Cohere

[Cohere](https://cohere.com/) brings you cutting-edge multilingual models, advanced retrieval, and an AI workspace tailored for the modern enterprise — all within a single, secure platform.

## Installation

The Strands Agents SDK provides access to Cohere models through the OpenAI compatiblity layer, configured as an optional dependency. To install, run:

```bash
pip install 'strands-agents[openai]'
```

## Usage

After installing `openai`, you can import and initialize Cohere models as follows:

```python
from strands import Agent
from strands.models.openai import OpenAIModel
from strands_tools import calculator

model = OpenAIModel(
client_args={
"base_url": "https://api.cohere.com/compatibility/v1",
"api_key": "<YOUR_KEY>",
},
model_id="command-a-03-2025",
stream=False,
params={
"stream_options": None
}
)

agent = Agent(model=model, tools=[calculator])
agent("What is 2+2")
```

## Configuration

### Client Configuration

The `client_args` and `params` configure the underlying OpenAI client. For a complete list of available arguments, please refer to the [OpenAI](https://github.com/openai/openai-python) and [Cohere](https://docs.cohere.com/docs/compatibility-api#supported-parameters) sources.

## Troubleshooting

### Module Not Found

If you encounter the error `ModuleNotFoundError: No module named 'openai'`, this means you haven't installed the `openai` dependency in your environment. To fix, run `pip install 'strands-agents[openai]'`.

## References

- [API](../../../api-reference/models.md)
- [OpenAI](https://platform.openai.com/docs/overview)
- [Cohere](https://docs.cohere.com/v2/cohere-documentation)