OpenAICloudflare Developer PlatformMar 19, 2026, 12:00 AM

Workers AI - Moonshot AI Kimi K2.5 now available on Workers AI

A condensed section focused on the key takeaways first.

Original Post

Quick Digest

Summary

A condensed section focused on the key takeaways first.

openaienmodel: gpt-5-mini-2025-08-07

Moonshot AI Kimi K2.5 now available on Workers AI

Key Points

  • 256k-token context window
  • prefix caching with discounted cached tokens
  • pull-based async batch API (queueRequest: true)

Summary

Moonshot AI Kimi K2.5 (@cf/moonshotai/kimi-k2.5) is now available on Workers AI. It's a frontier-scale open-source model with a full 256k token context window, multi-turn tool calling, vision inputs, structured JSON outputs, function calling, and prefix caching. The model runs on Cloudflare's Developer Platform so you can operate the full agent lifecycle (inference, tools, and orchestration) in one place with lower cost and high throughput.

Key Points

  • 256,000-token context window to retain full conversation history, tool definitions, and large codebases across long-running agent sessions.
  • Multi-turn tool calling and function calling to build agents that invoke external tools/APIs across multiple turns.
  • Vision inputs to process images alongside text and return structured outputs.
  • Structured outputs with JSON mode and JSON Schema support for reliable downstream parsing.
  • Prefix caching + session affinity: shared session context is cached to reduce prefill work, improving Time To First Token (TTFT) and Tokens Per Second (TPS); cached tokens are now surfaced as a usage metric and billed at a discount vs input tokens.
  • Redesigned asynchronous, pull-based Batch API: submit batches with queueRequest: true, receive a request_id, and poll or use event notifications; internal tests typically complete async requests within ~5 minutes (depends on live traffic).
  • Access routes: Workers AI binding (env.AI.run()), REST endpoints (/run or /v1/chat/completions), AI Gateway, or OpenAI-compatible endpoint. Session affinity can be set with the x-session-affinity header.

Practical notes for engineers

  • Use prefix caching and session affinity for long-lived agents to reduce compute and cost.
  • For high-volume non-real-time workloads (code scanning, research agents), use the async batch API to avoid capacity errors.
  • Check the model page, pricing, and prompt-caching docs for token billing details and cached-token discounts before production rollout.

Full Translation

Translations

A translation section that keeps the flow of the original article.

openaijamodel: gpt-5-mini-2025-08-07

Workers AI - Moonshot AI Kimi K2.5 が Workers AI で利用可能になりました

Moonshot AI Kimi K2.5 が Workers AI で利用可能に

Workers AI は公式に大規模モデルの領域に参入しました。@cf/moonshotai/kimi-k2.5 は我々の AI 推論プラットフォーム上で動作する最初のフロンティアスケールなオープンソースモデルです — 256k の完全なコンテキストウィンドウ、マルチターンのツール呼び出し、ビジョン入力、構造化出力を備えた大規模モデルです。フロンティアスケールのモデルを Cloudflare Developer Platform に直接搭載することで、単一の統合プラットフォーム上でエージェントのライフサイクル全体を実行できます。品質を損なうことなく、より大きな独自モデルに対する高速で効率的な代替として実証されています。AI の採用が進むにつれて推論量は急増しており、フロンティアインテリジェンスをより低コストで利用できるようになりました。

主な機能

  • 256,000 token context window で、長時間実行されるエージェントセッション中に会話履歴、ツール定義、コードベース全体を保持
  • マルチターンのツール呼び出しにより、複数の会話ターンにわたってツールを呼び出すエージェントを構築可能
  • ビジョン入力を使ってテキストと並列して画像を処理
  • JSON モードと JSON Schema サポートを備えた構造化出力で下流の解析を信頼性高く実行
  • Function calling により外部ツールや API をエージェントワークフローに統合
  • Prefix caching と session affinity

Prefix caching と session affinity

エージェントが新しいプロンプトを送るとき、セッション内の以前のすべてのプロンプト、ツール、コンテキストが再送信されます。連続するリクエスト間の差分は通常数行程度の新しい入力だけです。Prefix caching は共有コンテキストの再処理を避け、prefill ステージから時間と計算を節約します。これにより Time to First Token (TTFT) の短縮と Tokens Per Second (TPS) のスループット向上が得られます。Workers AI は以前から prefix caching を行ってきましたが、今回キャッシュ済みトークンを使用量メトリクスとして公開し、入力トークンに比べてキャッシュトークンに割引を提供します(価格はモデルページに記載)。

端末の例

curl -X POST \ 
 "https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/run/@cf/moonshotai/kimi-k2.5" \ 
 -H "Authorization: Bearer {api_token}" \ 
 -H "Content-Type: application/json" \ 
 -H "x-session-affinity: ses_12345678" \ 
 -d '{ "messages": [ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What is prefix caching and why does it matter?" } ], "max_tokens": 2400, "stream": true }'

一部のクライアント(OpenCode ↗ など)は session affinity を自動で実装します。Agents SDK ↗ のスターターも配線を設定します。

非同期 API の再設計

同期レート制限を超える量のリクエストに対しては、推論のバッチを非同期で完了するように送信できます。Asynchronous Batch API をプルベースのシステムに改良し、キャパシティが利用可能になり次第キューに入ったリクエストを処理します。社内テストでは、非同期リクエストは通常 5 分以内に実行されますが、これはライブトラフィックに依存します。非同期 API は、耐久的なワークフローでキャパシティエラーを回避する最良の方法です。リアルタイムではないユースケース(コードスキャンエージェントやリサーチエージェントなど)に適しています。

非同期 API を使うには、queueRequest: true を渡します:

// 1. Push a batch of requests into the queue
const res = await env.AI.run(
  "@cf/moonshotai/kimi-k2.5",
  {
    requests: [
      {
        messages: [
          { role: "user", content: "Tell me a joke" },
        ],
      },
      {
        messages: [
          { role: "user", content: "Explain the Pythagoras theorem" },
        ],
      },
    ],
  },
  { queueRequest: true },
);

// 2. Grab the request ID
const requestId = res.request_id;

// 3. Poll for the result
const result = await env.AI.run("@cf/moonshotai/kimi-k2.5", { request_id: requestId });

if (result.status === "queued" || result.status === "running") {
  // Retry by polling again
} else {
  return Response.json(result);
}

イベント通知を設定して、ポーリングの代わりに推論完了を受け取ることもできます。

利用開始

Kimi K2.5 は Workers AI バインディング(env.AI.run())、REST API の /run または /v1/chat/completions、AI Gateway、または OpenAI 互換エンドポイント経由で利用できます。詳細は Kimi K2.5 モデルページ、pricing、prompt caching を参照してください。

Workers AI - Moonshot AI Kimi K2.5 now available on Workers AI | Cloudflare Developer Platform | DocsDigest