Skip to content

Commit 346734e

Browse files
Cerebras provider
1 parent b67f1cd commit 346734e

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
title: Cerebras
3+
pcx_content_type: get-started
4+
---
5+
6+
[Cerebras](https://inference-docs.cerebras.ai/) offers developers a low-latency solution for AI model inference.
7+
8+
## Endpoint
9+
10+
```txt
11+
https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/cerebras-ai
12+
```
13+
14+
## Prerequisites
15+
16+
When making requests to Cerebras, ensure you have the following:
17+
18+
- Your AI Gateway Account ID.
19+
- Your AI Gateway gateway name.
20+
- An active Cerebras API token.
21+
- The name of the Cerebras model you want to use.
22+
23+
## Examples
24+
25+
### cURL
26+
27+
```bash title="Example fetch request"
28+
curl -X POST https://gateway.ai.cloudflare.com/v1/ACCOUNT_TAG/GATEWAY/cerebras/chat/completions \
29+
--header 'content-type: application/json' \
30+
--header 'Authorization: Bearer CEREBRAS_TOKEN' \
31+
--data '{
32+
"model": "llama3.1-8b",
33+
"messages": [
34+
{
35+
"role": "user",
36+
"content": "What is Cloudflare?"
37+
}
38+
]
39+
}'
40+
```
41+
42+
### Use Cerebras through Cerebras Cloud SDK with JavaScript
43+
44+
```js title="JavaScript"
45+
import Cerebras from "@cerebras/cerebras_cloud_sdk";
46+
47+
const client = new Cerebras({
48+
apiKey: process.env["CEREBRAS_API_KEY"], // This is the default and can be omitted
49+
});
50+
51+
async function main() {
52+
const completionCreateResponse = await client.chat.completions.create({
53+
messages: [{ role: "user", content: "Why is fast inference important?" }],
54+
model: "llama3.1-8b",
55+
});
56+
57+
console.log(completionCreateResponse);
58+
}
59+
60+
main();
61+
```

0 commit comments

Comments
 (0)