From 06b1bee953489ecad7b5429323972f67f8ca5eca Mon Sep 17 00:00:00 2001 From: daisyfaithauma Date: Thu, 2 Jan 2025 19:52:15 +0000 Subject: [PATCH] [AIG]DeepSeek initial documentation (#18973) * DeepSeek initial documentation * Update src/content/docs/ai-gateway/providers/deepseek.mdx Co-authored-by: Jun Lee * Update src/content/docs/ai-gateway/providers/deepseek.mdx Co-authored-by: Jun Lee * Update src/content/docs/ai-gateway/providers/deepseek.mdx Co-authored-by: Jun Lee * Update src/content/docs/ai-gateway/providers/deepseek.mdx Co-authored-by: Jun Lee * Update deepseek.mdx fixed model in curl --------- Co-authored-by: Jun Lee Co-authored-by: Kathy <153706637+kathayl@users.noreply.github.com> --- .../docs/ai-gateway/providers/deepseek.mdx | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 src/content/docs/ai-gateway/providers/deepseek.mdx diff --git a/src/content/docs/ai-gateway/providers/deepseek.mdx b/src/content/docs/ai-gateway/providers/deepseek.mdx new file mode 100644 index 000000000000000..7ea7a86d4278d72 --- /dev/null +++ b/src/content/docs/ai-gateway/providers/deepseek.mdx @@ -0,0 +1,82 @@ +--- +title: DeepSeek AI +pcx_content_type: get-started +sidebar: + badge: + text: Beta +--- + +[DeepSeek AI](https://www.deepseek.com/) helps you build quickly with DeepSeek's advanced AI models. + +## Endpoint + +```txt +https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/deepseek +``` + +## Prerequisites + +When making requests to DeepSeek AI, you will need: + +- AI Gateway Account ID +- AI Gateway gateway name +- DeepSeek AI API token +- DeepSeek AI model name + +## URL structure + +Your new base URL will use the data above in this structure: + +`https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/deepseek/`. + +You can then append the endpoint you want to hit, for example: `chat/completions`. + +So your final URL will come together as: + +`https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/deepseek/chat/completions`. + +## Examples + +### cURL + +```bash title="Example fetch request" +curl https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/deepseek/chat/completions \ + --header 'content-type: application/json' \ + --header 'Authorization: Bearer DEEPSEEK_TOKEN' \ + --data '{ + "model": "deepseek-chat", + "messages": [ + { + "role": "user", + "content": "What is Cloudflare?" + } + ] +}' +``` + +### Use `openai` package with JavaScript + +If you are using the `openai` package, you can set your endpoint like this: + +```js title="JavaScript example" +import OpenAI from "openai"; + +const openai = new OpenAI({ + apiKey: env.DEEPSEEK_TOKEN, + baseURL: + "https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/deepseek", +}); + +try { + const chatCompletion = await openai.chat.completions.create({ + model: "deepseek-chat", + messages: [{ role: "user", content: "What is Cloudflare?" }], + }); + + const response = chatCompletion.choices[0].message; + + return new Response(JSON.stringify(response)); +} catch (e) { + return new Response(e); +} +```