Skip to content

非公式本サイトは非公式の日本語ドキュメントであり、Cloudflare 公式サイトではありません。最新情報はdevelopers.cloudflare.comをご確認ください。

DeepSeek

最終更新 Markdown で表示Agent セットアップ

DeepSeek の高度な AI モデルで、すばやく構築できます。

エンドポイント

https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/deepseek

前提条件

DeepSeek にリクエストするときは、次を用意してください。

  • AI Gateway の Account ID
  • AI Gateway のゲートウェイ名
  • 有効な DeepSeek AI の API トークン
  • 使う DeepSeek AI モデルの名前

URL の構成

新しいベース 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

リクエストの例bash
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?"
        }
    ]
}'

JavaScript で DeepSeek を使う

OpenAI SDK を使っている場合は、エンドポイントを次のように設定できます。

JavaScriptjs
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);
}

OpenAI 互換エンドポイント

REST API 経由で、OpenAI API スキーマを使って DeepSeek モデルにもアクセスできます。リクエストの送信先は次のとおりです。

https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/v1/chat/completions

次を指定します。


{
"model": "deepseek/{model}"
}

役に立ちましたか?