DeepSeek ↗ の高度な AI モデルで、すばやく構築できます。
https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/deepseekDeepSeek にリクエストするときは、次を用意してください。
- AI Gateway の Account ID
- AI Gateway のゲートウェイ名
- 有効な 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);
}REST API 経由で、OpenAI API スキーマを使って DeepSeek モデルにもアクセスできます。リクエストの送信先は次のとおりです。
https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/v1/chat/completions次を指定します。
{
"model": "deepseek/{model}"
}