# Working with Cohere's API and SDK

> Cohere's NLP platform provides customizable large language models and tools for developers to build AI applications.

The Cohere platform allows you to leverage the power of [large language models](https://docs.cohere.com/v1/docs/the-cohere-platform#large-language-models-llms) (LLMs) with just a few lines of code and an [API key](https://dashboard.cohere.com/api-keys?_gl=1*14v2pj5*_gcl_au*NTczMTgyMTIzLjE3MzQ1NTY2OTA.*_ga*MTAxNTg1NTM1MS4xNjk1MjMwODQw*_ga_CRGS116RZS*MTczNjI3NzU2NS4xOS4xLjE3MzYyODExMTkuNDkuMC4w).

Our [Command](https://docs.cohere.com/v1/docs/command-r7b), [Embed](https://docs.cohere.com/v1/docs/cohere-embed), [Rerank](https://docs.cohere.com/v1/docs/rerank), and [Aya](https://docs.cohere.com/v1/docs/aya) models excel at a variety of applications, from the relatively simple ([semantic search](https://docs.cohere.com/v1/docs/semantic-search-embed), and [content generation](https://docs.cohere.com/v1/docs/introduction-to-text-generation-at-cohere)) to the more advanced ([retrieval augmented generation](https://docs.cohere.com/v1/docs/retrieval-augmented-generation-rag) and [agents](https://docs.cohere.com/v1/docs/multi-step-tool-use)). If you have a more specialized use case and custom data, you can also [train a custom model](https://docs.cohere.com/v1/docs/fine-tuning) to get better performance.

Check out [our documentation](https://docs.cohere.com/v1/docs/the-cohere-platform) if you're ready to start building, and you might want to check out our [API pricing](https://docs.cohere.com/v1/docs/rate-limits).

## 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](https://github.com/cohere-ai/cohere-python)

```bash
python -m pip install cohere --upgrade
```

```python
import cohere

co = cohere.ClientV2("<<apiKey>>")
response = co.chat(
    model="command-a-03-2025", 
    messages=[{"role": "user", "content": "hello world!"}]
)

print(response)
```

### Typescript

[https://github.com/cohere-ai/cohere-typescript](https://github.com/cohere-ai/cohere-typescript)

```bash
npm i -s cohere-ai
```

```typescript
const { CohereClientV2 } = require('cohere-ai');

const cohere = new CohereClientV2({
  token: '<<apiKey>>',
});

(async () => {
  const response = await cohere.chat({
    model: 'command-a-03-2025',
    messages: [
      {
        role: 'user',
        content: 'hello world!',
      },
    ],
  });

  console.log(response);
})();
```

### Java

[https://github.com/cohere-ai/cohere-java](https://github.com/cohere-ai/cohere-java)

```gradle
implementation 'com.cohere:cohere-java:1.x.x'
```

```java
package chatv2post;

import com.cohere.api.Cohere;
import com.cohere.api.resources.v2.requests.V2ChatRequest;
import com.cohere.api.types.*;
import java.util.List;

public class Default {
    public static void main(String[] args) {
        Cohere cohere = Cohere.builder().token("<<apiKey>>").clientName("snippet").build();

        ChatResponse response =
                cohere.v2()
                        .chat(
                                V2ChatRequest.builder()
                                    .model("command-a-03-2025")
                                    .messages(
                                        List.of(
                                            ChatMessageV2.user(
                                                UserMessage.builder()
                                                    .content(
                                                        UserMessageContent
                                                                .of("Hello world!"))
                                                    .build())))
                                    .build());

        System.out.println(response);
    }
}
```

### Go

[https://github.com/cohere-ai/cohere-go](https://github.com/cohere-ai/cohere-go)

```bash
go get github.com/cohere-ai/cohere-go/v2
```

```go
package main

import (
	"context"
	"log"

	cohere "github.com/cohere-ai/cohere-go/v2"
	client "github.com/cohere-ai/cohere-go/v2/client"
)

func main() {
	co := client.NewClient(client.WithToken("Your API key"))

	resp, err := co.Chat(
		context.TODO(),
		&cohere.ChatRequest{
			Message: "Hello world!",
		},
	)

	if err != nil {
		log.Fatal(err)
	}

	log.Printf("%+v", resp)
}

```

## 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.