Cohere Provider

The Cohere provider contains language model support for the Cohere chat API.


The Cohere provider is available in the @ai-sdk/cohere module. You can install it with

pnpm install @ai-sdk/cohere

Provider Instance

You can import the default provider instance cohere from @ai-sdk/cohere:

import { cohere } from '@ai-sdk/cohere';

If you need a customized setup, you can import createCohere from @ai-sdk/cohere and create a provider instance with your settings:

import { createCohere } from '@ai-sdk/cohere';
const cohere = createCohere({
// custom settings

You can use the following optional settings to customize the Cohere provider instance:

  • baseURL string

    Use a different URL prefix for API calls, e.g. to use proxy servers. The default prefix is

  • apiKey string

    API key that is being send using the Authorization header. It defaults to the COHERE_API_KEY environment variable.

  • headers Record<string,string>

    Custom headers to include in the requests.

  • fetch (input: RequestInfo, init?: RequestInit) => Promise<Response>

    Custom fetch implementation. Defaults to the global fetch function. You can use it as a middleware to intercept requests, or to provide a custom fetch implementation for e.g. testing.

Language Models

You can create models that call the Cohere chat API using provider instance. The first argument is the model id, e.g. command-r-plus. Some Cohere chat models support tool calls.

const model = cohere('command-r-plus');


You can use Cohere language models to generate text with the generateText function:

import { cohere } from '@ai-sdk/cohere';
import { generateText } from 'ai';
const { text } = await generateText({
model: cohere('command-r-plus'),
prompt: 'Write a vegetarian lasagna recipe for 4 people.',

Cohere language models can also be used in the streamText function (see AI SDK Core).

Model Capabilities

ModelImage InputObject GenerationTool UsageTool Streaming