๐Ÿš€ New multimodal model: Command A Vision! (Learn more) ๐Ÿš€

Working with Cohere's API and SDK

The Cohere platform allows you to leverage the power of large language models (LLMs) with just a few lines of code and an API key.

Our Command, Embed, Rerank, and Aya models excel at a variety of applications, from the relatively simple (semantic search, and content generation) to the more advanced (retrieval augmented generation and agents). If you have a more specialized use case and custom data, you can also train a custom model to get better performance.

Check out our documentation if youโ€™re ready to start building, and you might want to check out our API pricing.

SDKs

The Cohere SDK is the primary way of accessing Cohereโ€™s models. We support SDKs in four different languages. To get started, please see the installation methods and code snippets below.

Python

https://github.com/cohere-ai/cohere-python

$python -m pip install cohere --upgrade
1import cohere
2
3co = cohere.ClientV2("<<apiKey>>")
4response = co.chat(
5 model="command-a-03-2025",
6 messages=[{"role": "user", "content": "hello world!"}]
7)
8
9print(response)

Typescript

https://github.com/cohere-ai/cohere-typescript

$npm i -s cohere-ai
1const { CohereClientV2 } = require('cohere-ai');
2
3const cohere = new CohereClientV2({
4 token: '<<apiKey>>',
5});
6
7(async () => {
8 const response = await cohere.chat({
9 model: 'command-a-03-2025',
10 messages: [
11 {
12 role: 'user',
13 content: 'hello world!',
14 },
15 ],
16 });
17
18 console.log(response);
19})();

Java

https://github.com/cohere-ai/cohere-java

1implementation 'com.cohere:cohere-java:1.x.x'
1package chatv2post;
2
3import com.cohere.api.Cohere;
4import com.cohere.api.resources.v2.requests.V2ChatRequest;
5import com.cohere.api.types.*;
6import java.util.List;
7
8public class Default {
9 public static void main(String[] args) {
10 Cohere cohere = Cohere.builder().token("<<apiKey>>").clientName("snippet").build();
11
12 ChatResponse response =
13 cohere.v2()
14 .chat(
15 V2ChatRequest.builder()
16 .model("command-a-03-2025")
17 .messages(
18 List.of(
19 ChatMessageV2.user(
20 UserMessage.builder()
21 .content(
22 UserMessageContent
23 .of("Hello world!"))
24 .build())))
25 .build());
26
27 System.out.println(response);
28 }
29}

Go

https://github.com/cohere-ai/cohere-go

$go get github.com/cohere-ai/cohere-go/v2
1package main
2
3import (
4 "context"
5 "log"
6
7 cohere "github.com/cohere-ai/cohere-go/v2"
8 client "github.com/cohere-ai/cohere-go/v2/client"
9)
10
11func main() {
12 co := client.NewClient(client.WithToken("Your API key"))
13
14 resp, err := co.Chat(
15 context.TODO(),
16 &cohere.ChatRequest{
17 Message: "Hello world!",
18 },
19 )
20
21 if err != nil {
22 log.Fatal(err)
23 }
24
25 log.Printf("%+v", resp)
26}

Request Specification

To make a request to any model, you must pass in the Authorization Header and the request must be made through a POST request.

The content of Authorization should be in the shape of BEARER [API_KEY]. All request bodies are sent through JSON.

Model names are found within the dashboard, and details about endpoints are available within the documentation.