-
Notifications
You must be signed in to change notification settings - Fork 70
Expand file tree
/
Copy pathabout.mdx
More file actions
157 lines (116 loc) · 4.82 KB
/
about.mdx
File metadata and controls
157 lines (116 loc) · 4.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
---
title: Working with Cohere's API and SDK
slug: reference/about
hidden: false
description: >-
Cohere's NLP platform provides customizable large language models and tools
for developers to build AI applications.
keywords: 'RAG, retrieval, augmented, generation, LLM, connectors, connector, langchain'
createdAt: 'Wed Sep 14 2022 16:37:41 GMT+0000 (Coordinated Universal Time)'
updatedAt: 'Fri Jun 14 2024 16:36:59 GMT+0000 (Coordinated Universal Time)'
---
The Cohere platform allows you to leverage the power of [large language models](../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](../docs/command-r7b), [Embed](../docs/cohere-embed), [Rerank](../docs/rerank), [Aya](../docs/aya), and [Cohere Transcribe](../docs/transcribe) models excel at a variety of applications, from the relatively simple ([semantic search](../docs/semantic-search-embed), and [content generation](../docs/introduction-to-text-generation-at-cohere)) to the more advanced ([retrieval augmented generation](../docs/retrieval-augmented-generation-rag) and [agents](../docs/multi-step-tool-use)). If you have a more specialized use case and custom data, you can also [train a custom model](../docs/fine-tuning) to get better performance.
Check out [our documentation](../docs/the-cohere-platform) if you're ready to start building, and you might want to check out our [API pricing](../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.