Skip to content

Commit 4060c29

Browse files
DeepSeek initial documentation
1 parent 05d6c9a commit 4060c29

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
title: DeepSeek AI
3+
pcx_content_type: get-started
4+
sidebar:
5+
badge:
6+
text: Beta
7+
---
8+
9+
[DeepSeek AI](https://www.deepseek.com/) helps you build quickly with DeepSeek's advanced AI models.
10+
11+
## Endpoint
12+
13+
```txt
14+
https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/deepseek
15+
```
16+
17+
## What you need
18+
19+
When making requests to DeepSeek AI, you will need:
20+
21+
- AI Gateway Account ID
22+
- AI Gateway gateway name
23+
- DeepSeek AI API token
24+
- DeepSeek AI model name
25+
26+
## URL structure
27+
28+
Your new base URL will use the data above in this structure:
29+
`https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/deepseek/`.
30+
31+
Then you can append the endpoint you want to hit, for example: `chat/completions`.
32+
33+
So your final URL will come together as:
34+
`https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/deepseek/chat/completions`.
35+
36+
## Examples
37+
38+
### cURL
39+
40+
```bash title="Example fetch request"
41+
curl https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/deepseek/chat/completions \
42+
--header 'content-type: application/json' \
43+
--header 'Authorization: Bearer DEEPSEEK_TOKEN' \
44+
--data '{
45+
"model": "openai/gpt-3.5-turbo",
46+
"messages": [
47+
{
48+
"role": "user",
49+
"content": "What is Cloudflare?"
50+
}
51+
]
52+
}'
53+
```
54+
55+
### Use `openai` package with JavaScript
56+
57+
If you are using the `openai` package, you can set your endpoint like this:
58+
59+
```js title="JavaScript example"
60+
import OpenAI from "openai";
61+
62+
const openai = new OpenAI({
63+
apiKey: env.DEEPSEEK_TOKEN,
64+
baseURL:
65+
"https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/deepseek",
66+
});
67+
68+
try {
69+
const chatCompletion = await openai.chat.completions.create({
70+
model: "deepseek-chat",
71+
messages: [{ role: "user", content: "What is Cloudflare?" }],
72+
});
73+
74+
const response = chatCompletion.choices[0].message;
75+
76+
return new Response(JSON.stringify(response));
77+
} catch (e) {
78+
return new Response(e);
79+
}
80+
```

0 commit comments

Comments
 (0)