---
id: gh-k2
name: "k2"
url: https://skills.yangsir.net/skill/gh-k2
author: cloudflare
domain: cloud-infra
tags: ["cloudflare", "k2", "streams", "serverless", "durable-logs"]
install_count: 17900
rating: 4.60 (120 reviews)
github: https://github.com/cloudflare/skills/tree/main/skills/k2
---

# k2

> 该 Skill 用于构建和排查 Cloudflare K2 及 K2 Streams 持久化日志服务。它覆盖流的创建与配置、从 Workers 或 HTTP 生产记录、设置保留策略与输入认证，以及通过订阅消费记录。适合在事件驱动架构中解耦生产者与消费者，并快速定位容量、配额与投递行为问题。

**Stats**: 17,900 installs · 4.6/5 (120 reviews)

## Before / After 对比

### K2 流接入与消费流程搭建

**Before**:

开发者要在多个文档页之间反复切换，手动比对流的输入认证、保留策略与订阅租约语义，常常写下已经过时的 API 示例，最后在调试投递失败上耗费大量时间。

**After**:

此技能按任务直接定位对应的当前文档页，给出生产与消费的可用示例，并明确说明配额与投递行为，让流从创建到订阅消费一次跑通。

| Metric | Before | After | Change |
|---|---|---|---|
| 接入调试耗时 | 180分钟 | 25分钟 | -86% |
| 配置返工次数 | 5次 | 1次 | -80% |
| 文档查阅页面数 | 9个 | 2个 | -78% |

## Readme

# Cloudflare K2

K2 is a durable log for decoupling event producers and consumers. Start with the [K2 overview](https://developers.cloudflare.com/k2/index.md), then retrieve the relevant current documentation before giving setup instructions, code, limits, availability, permissions, or API details. The docs are the source of truth over this skill. While [cloudflare-docs PR #33858](https://github.com/cloudflare/cloudflare-docs/pull/33858) remains open, use its proposed pages if the public URLs have not been published.

## Documentation

| Task | Docs | Check for |
|------|------|-----------|
| Create a stream and try K2 | [Get started](https://developers.cloudflare.com/k2/get-started/index.md) | Prerequisites, setup sequence, current API examples |
| Understand streams and subscriptions | [Concepts](https://developers.cloudflare.com/k2/concepts/index.md) | Record model and delivery behavior |
| Configure a stream | [Configuration](https://developers.cloudflare.com/k2/configuration/index.md) | Inputs, authentication, CORS, retention |
| Produce from HTTP or a Worker | [Produce records](https://developers.cloudflare.com/k2/features/produce/index.md) | Request and binding syntax, encoding, errors, retries |
| Consume through subscriptions | [Consume records](https://developers.cloudflare.com/k2/features/consume/index.md) | Leases, acknowledgements, retries, errors |
| Size a stream or consumer | [Limits](https://developers.cloudflare.com/k2/platform/limits/index.md) | Current quotas and size limits |

Retrieve the matching pages above for each task and use their current examples. For capacity or cost questions, check current limits and any published pricing before quoting values. State when a requested pricing or availability detail is not yet published.

For SQL transformation and delivery to R2 Iceberg tables, use the `basin` skill. For task processing, consult [Queues](https://developers.cloudflare.com/queues/index.md).


---
*Source: https://skills.yangsir.net/skill/gh-k2*
*Markdown mirror: https://skills.yangsir.net/api/skill/gh-k2/markdown*