- Cloudflare-hosted
- Function calling
- Reasoning
- Vision
Kimi K2.7 是一款前沿规模的开源模型,拥有 1T 参数和 262.1k 上下文窗口,支持多轮工具调用、视觉输入和结构化输出,适用于智能体工作负载。
| 模型信息 | |
|---|---|
| 上下文窗口 ↗ | 262,144 个 token |
| 条款和许可证 | 链接 ↗ |
| 函数调用 ↗ | 是 |
| 推理 | 是 |
| 视觉 | 是 |
| 单位定价 | $0.95 per M input tokens, $4.00 per M output tokens, $0.19 per M cached input 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/moonshotai/kimi-k2.7-code", {
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/moonshotai/kimi-k2.7-code", { 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/moonshotai/kimi-k2.7-code",
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/moonshotai/kimi-k2.7-code \
-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供模型生成响应的输入文本提示词。model
string要使用的模型 ID(例如 '@cf/zai-org/glm-4.7-flash, etc')。▶audio{}
object音频输出的参数。当 modalities 包含 'audio' 时必填。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是否在使用工具时启用并行函数调用。▶prediction{}
objectpresence_penalty
number | null根据新 token 是否已在目前文本中出现对其进行惩罚。reasoning_effort
string | null限制推理模型(o1、o3-mini 等)的推理投入程度。▶chat_template_kwargs{}
object▶response_format
one of指定模型必须输出的格式。seed
integer | null如果指定,系统将尽最大努力进行确定性采样。service_tier
string | null指定处理该请求所使用的处理类型。▶stop
one ofstore
boolean | null是否存储输出以用于模型蒸馏/评估。stream
boolean | null如果为 true,部分消息增量将以服务器发送事件(server-sent events)的形式发送。▶stream_options{}
objecttemperature
number | null采样温度,介于 0 到 2 之间。▶tool_choice
one of控制模型调用哪个工具(如有)。'none' = 不调用工具,'auto' = 由模型决定,'required' = 必须调用工具。▶tools[]
array模型可调用的工具列表。top_p
number | null核采样(nucleus sampling):只考虑累计概率质量达到 top_p 的 token 结果。user
string代表您的最终用户的唯一标识符,用于滥用监测。▶web_search_options{}
objectWeb 搜索工具的选项(使用内置 Web 搜索时)。▶function_call
one of▶functions[]
arrayminItems: 1maxItems: 128id
string聊天补全的唯一标识符。object
stringcreated
integer补全创建时的 Unix 时间戳(秒)。model
string聊天补全所使用的模型。▶choices[]
arrayminItems: 1▶usage{}
objectsystem_fingerprint
string | nullservice_tier
string | nullStreaming — Send a request with `stream: true` and receive server-sent events
prompt
stringrequiredminLength: 1供模型生成响应的输入文本提示词。model
string要使用的模型 ID(例如 '@cf/zai-org/glm-4.7-flash, etc')。▶audio{}
object音频输出的参数。当 modalities 包含 'audio' 时必填。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是否在使用工具时启用并行函数调用。▶prediction{}
objectpresence_penalty
number | null根据新 token 是否已在目前文本中出现对其进行惩罚。reasoning_effort
string | null限制推理模型(o1、o3-mini 等)的推理投入程度。▶chat_template_kwargs{}
object▶response_format
one of指定模型必须输出的格式。seed
integer | null如果指定,系统将尽最大努力进行确定性采样。service_tier
string | null指定处理该请求所使用的处理类型。▶stop
one ofstore
boolean | null是否存储输出以用于模型蒸馏/评估。stream
boolean | null如果为 true,部分消息增量将以服务器发送事件(server-sent events)的形式发送。▶stream_options{}
objecttemperature
number | null采样温度,介于 0 到 2 之间。▶tool_choice
one of控制模型调用哪个工具(如有)。'none' = 不调用工具,'auto' = 由模型决定,'required' = 必须调用工具。▶tools[]
array模型可调用的工具列表。top_p
number | null核采样(nucleus sampling):只考虑累计概率质量达到 top_p 的 token 结果。user
string代表您的最终用户的唯一标识符,用于滥用监测。▶web_search_options{}
objectWeb 搜索工具的选项(使用内置 Web 搜索时)。▶function_call
one of▶functions[]
arrayminItems: 1maxItems: 128type
stringcontentType
text/event-streamformat
binaryBatch — Send multiple requests in a single API call
▶requests[]
arrayid
string聊天补全的唯一标识符。object
stringcreated
integer补全创建时的 Unix 时间戳(秒)。model
string聊天补全所使用的模型。▶choices[]
arrayminItems: 1▶usage{}
objectsystem_fingerprint
string | nullservice_tier
string | null