跳转到内容
本站为社区维护的非官方中文翻译,与 Cloudflare, Inc. 无关联。本站不提供账户登录,请勿在任何非官方站点输入您的 Cloudflare 账户信息。官方文档:developers.cloudflare.com
Google logo

gemma-4-26b-a4b-it

Text Generation • Google

查看 MarkdownAgent 设置
  • Cloudflare-hosted
  • Function calling
  • Reasoning
  • Vision

Gemma 4 是 Google 最智能的开放模型系列,基于 Gemini 3 的研究成果构建,旨在最大化每个参数的智能水平。

模型信息
上下文窗口 ↗256,000 个 token
条款和许可证链接 ↗
函数调用 ↗是
推理是
视觉是
单位定价$0.10 per M input tokens, $0.30 per M output tokens

试用环境

使用 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("@cf/google/gemma-4-26b-a4b-it", {
      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("@cf/google/gemma-4-26b-a4b-it", { 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/@cf/google/gemma-4-26b-a4b-it",
    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/@cf/google/gemma-4-26b-a4b-it \
  -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" }]}'

参数

Synchronous — Send a request and receive a complete response
输入格式
prompt
stringrequiredminLength: 1供模型生成响应的输入文本提示词。
skip_special_tokens
booleandefault: false
model
string要使用的模型 ID(例如 '@cf/zai-org/glm-4.7-flash, etc')。
frequency_penalty
number | null根据新 token 在目前文本中已出现的频率对其进行惩罚。
logit_bias
object | null修改指定 token 在补全中出现的可能性。将 token ID 映射到 -100 到 100 之间的偏置值。
logprobs
boolean | null是否返回输出 token 的对数概率。
top_logprobs
integer | null在每个 token 位置返回多少个最高的对数概率(0-20)。需要 logprobs=true。
max_tokens
integer | null已弃用,请改用 max_completion_tokens。要生成的最大 token 数。
max_completion_tokens
integer | null补全中可生成 token 数的上限。
metadata
object | null可附加到对象上的一组键值对(最多 16 个)。
modalities
array | null请求模型输出的类型(例如 ['text'] 或 ['text', 'audio'])。
n
integer | null为每条输入消息生成多少个聊天补全选项。
parallel_tool_calls
booleandefault: true是否在使用工具时启用并行函数调用。
presence_penalty
number | null根据新 token 是否已在目前文本中出现对其进行惩罚。
reasoning_effort
string | null限制推理模型(o1、o3-mini 等)的推理投入程度。
seed
integer | null如果指定,系统将尽最大努力进行确定性采样。
service_tier
string | null指定处理该请求所使用的处理类型。
store
boolean | null是否存储输出以用于模型蒸馏/评估。
stream
boolean | null如果为 true,部分消息增量将以服务器发送事件(server-sent events)的形式发送。
temperature
number | null采样温度,介于 0 到 2 之间。
top_p
number | null核采样(nucleus sampling):只考虑累计概率质量达到 top_p 的 token 结果。
user
string代表您的最终用户的唯一标识符,用于滥用监测。
id
string聊天补全的唯一标识符。
object
string
created
integer补全创建时的 Unix 时间戳(秒)。
model
string聊天补全所使用的模型。
system_fingerprint
string | null
service_tier
string | null
Streaming — Send a request with `stream: true` and receive server-sent events
输入格式
prompt
stringrequiredminLength: 1供模型生成响应的输入文本提示词。
skip_special_tokens
booleandefault: false
model
string要使用的模型 ID(例如 '@cf/zai-org/glm-4.7-flash, etc')。
frequency_penalty
number | null根据新 token 在目前文本中已出现的频率对其进行惩罚。
logit_bias
object | null修改指定 token 在补全中出现的可能性。将 token ID 映射到 -100 到 100 之间的偏置值。
logprobs
boolean | null是否返回输出 token 的对数概率。
top_logprobs
integer | null在每个 token 位置返回多少个最高的对数概率(0-20)。需要 logprobs=true。
max_tokens
integer | null已弃用,请改用 max_completion_tokens。要生成的最大 token 数。
max_completion_tokens
integer | null补全中可生成 token 数的上限。
metadata
object | null可附加到对象上的一组键值对(最多 16 个)。
modalities
array | null请求模型输出的类型(例如 ['text'] 或 ['text', 'audio'])。
n
integer | null为每条输入消息生成多少个聊天补全选项。
parallel_tool_calls
booleandefault: true是否在使用工具时启用并行函数调用。
presence_penalty
number | null根据新 token 是否已在目前文本中出现对其进行惩罚。
reasoning_effort
string | null限制推理模型(o1、o3-mini 等)的推理投入程度。
seed
integer | null如果指定,系统将尽最大努力进行确定性采样。
service_tier
string | null指定处理该请求所使用的处理类型。
store
boolean | null是否存储输出以用于模型蒸馏/评估。
stream
boolean | null如果为 true,部分消息增量将以服务器发送事件(server-sent events)的形式发送。
temperature
number | null采样温度,介于 0 到 2 之间。
top_p
number | null核采样(nucleus sampling):只考虑累计概率质量达到 top_p 的 token 结果。
user
string代表您的最终用户的唯一标识符,用于滥用监测。
type
string
contentType
text/event-stream
format
binary
Batch — Send multiple requests in a single API call
id
string聊天补全的唯一标识符。
object
string
created
integer补全创建时的 Unix 时间戳(秒)。
model
string聊天补全所使用的模型。
system_fingerprint
string | null
service_tier
string | null

API schema(原始)

Synchronous输入
Synchronous输出
Streaming输入
Streaming输出
Batch输入
Batch输出

这篇文档对您有帮助吗?