DeepSeek ↗ 帮助您使用 DeepSeek 的先进 AI 模型快速构建。
https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/deepseek
在向 DeepSeek 发出请求时,确保您具有以下内容:
- 您的 AI 网关账户 ID。
- 您的 AI 网关网关名称。
- 一个有效的 DeepSeek AI API 令牌。
- 您要使用的 DeepSeek AI 模型的名称。
您的新基础 URL 将使用上述数据的结构:
https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/deepseek/
。
然后您可以附加您要访问的端点,例如:chat/completions
。
因此您的最终 URL 将组合为:
https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/deepseek/chat/completions
。
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?" } ]}'
如果您使用 OpenAI SDK,您可以这样设置您的端点:
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);}
You can also use the OpenAI-compatible endpoint (/ai-gateway/chat-completion/
) to access DeepSeek models using the OpenAI API schema. To do so, send your requests to:
https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/compat/chat/completions
Specify:
{"model": "deepseek/{model}"}
- @2025 Cloudflare Ubitools
- Cf Repo