- Cloudflare ホスト
- 非推奨
Meta Llama 3 は世代を重ねるごとに、幅広い業界ベンチマークで最先端の性能を示し、推論の向上をはじめとする新しい能力を備えています。
| モデル情報 | |
|---|---|
| 非推奨 | 2026/5/30 |
| コンテキストウィンドウ ↗ | 8,192 トークン |
Workers AI LLM Playground でこのモデルを試せます。セットアップや認証は不要で、ブラウザからすぐにプレビューとテストができます。
LLM Playground を開く
export interface Env {
AI: Ai;
}
export default {
async fetch(request, env): Promise<Response> {
const messages = [
{ role: "system", content: "You are a friendly assistant" },
{
role: "user",
content: "What is the origin of the phrase Hello, World",
},
];
const stream = await env.AI.run("@hf/meta-llama/meta-llama-3-8b-instruct", {
messages,
stream: true,
});
return new Response(stream, {
headers: { "content-type": "text/event-stream" },
});
},
} satisfies ExportedHandler<Env>;
export interface Env {
AI: Ai;
}
export default {
async fetch(request, env): Promise<Response> {
const messages = [
{ role: "system", content: "You are a friendly assistant" },
{
role: "user",
content: "What is the origin of the phrase Hello, World",
},
];
const response = await env.AI.run("@hf/meta-llama/meta-llama-3-8b-instruct", { messages });
return Response.json(response);
},
} satisfies ExportedHandler<Env>;
import os
import requests
ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")
prompt = "Tell me all about PEP-8"
response = requests.post(
f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@hf/meta-llama/meta-llama-3-8b-instruct",
headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
json={
"messages": [
{"role": "system", "content": "You are a friendly assistant"},
{"role": "user", "content": prompt}
]
}
)
result = response.json()
print(result)
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@hf/meta-llama/meta-llama-3-8b-instruct \
-X POST \
-H "Authorization: Bearer $CLOUDFLARE_AUTH_TOKEN" \
-d '{ "messages": [{ "role": "system", "content": "You are a friendly assistant" }, { "role": "user", "content": "Why is pizza so good" }]}'入力
prompt
string必須minLength: 1モデルが応答を生成するための入力テキストプロンプトです。lora
stringベースモデルを微調整する LoRA(Low-Rank Adaptation)モデルの名前です。▶response_format{}
objectraw
booleanデフォルト: false`true` の場合、チャットテンプレートは適用されません。そのモデルが想定する形式に合わせてください。stream
booleanデフォルト: false`true` の場合、応答は SSE(Server-Sent Events)で順次ストリーミングされます。max_tokens
integerデフォルト: 256応答で生成するトークンの最大数です。temperature
numberデフォルト: 0.6minimum: 0maximum: 5出力のランダムさを制御します。値が高いほど結果がランダムになります。top_p
numberminimum: 0.001maximum: 1検討する語の数を制御して、応答の創造性を調整します。値が低いほど予測しやすく、高いほど多様で創造的になります。top_k
integerminimum: 1maximum: 50上位 k 個の候補語からのみ選ばせます。値が低いほど焦点が絞られ、高いほど多様になります。seed
integerminimum: 1maximum: 9999999999生成結果を再現するための乱数シードです。repetition_penalty
numberminimum: 0maximum: 2繰り返しトークンへのペナルティです。値が高いほど繰り返しを抑えます。frequency_penalty
numberminimum: -2maximum: 2同じ行をそのまま繰り返す可能性を下げます。presence_penalty
numberminimum: -2maximum: 2新しい話題を出す可能性を上げます。出力
同期 — リクエストを送り、完了した応答を受け取ります
response
stringモデルが生成したテキスト応答です▶usage{}
object推論リクエストの使用量統計です▶tool_calls[]
array応答生成中に行われたツール呼び出しリクエストの配列ですストリーミング — `stream: true` でリクエストを送り、server-sent events を受け取ります
type
stringformat
binary