Token导航 LogoToken导航TokenDH.com
前端设计敏感数据github未标认证来源可访问许可证需确认审计提醒

tl-openmeter-apiTL openmeter API 文档

Agent Skill

用于辅助 API 设计、接口文档、请求响应结构和服务集成说明。它适合让 Agent 梳理 endpoint、生成 OpenAPI 草稿、检查字段命名、整理错误码或辅助前后端联调。使用时需要确认真实业务语义、鉴权方式、分页和错误处理规则;涉及生成接口文档时,应避免凭空补字段,最好从现有代码、schema 或接口样例中提取事实。

总安装

288

周安装

12

GitHub Stars

公开资料未说明

下载量

96
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:tl-openmeter-api(TL openmeter API 文档)
来源仓库:https://github.com/toddlevy/tl-agent-skills
仓库路径:skills/tl-openmeter-api
安装命令:
npx skills add https://github.com/toddlevy/tl-agent-skills --skill tl-openmeter-api
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/toddlevy/tl-agent-skills --skill tl-openmeter-api

简介

tl-openmeter-api 用于辅助 API 设计、接口文档、请求响应结构和服务集成说明,适合梳理 endpoint 或生成 OpenAPI 草稿。

  • 适用于前后端联调和接口开发场景,需确认真实业务语义和鉴权方式。
  • 通过 npx skills add 命令从 GitHub 安装,支持主流 AI 宿主环境。
  • 涉及生成接口文档时应避免凭空补字段,安装前建议确认权限和维护状态。
  • 适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

SKILL.md

OpenMeter API

Project-agnostic reference for the OpenMeter REST API. Organized by the official API tags from the OpenAPI 3.0 spec.

Suite

SkillPurpose
tl-openmeter-apiThis skill: REST API reference
tl-openmeter-local-devLocal dev setup: Docker, ngrok, Stripe App, webhooks
tl-openmeter-api-mcp-serverMCP server for calling local OpenMeter from Cursor

When to Use

  • "How do I ingest events into OpenMeter?"
  • "Create an OpenMeter customer with subscription"
  • "Query usage for a meter"
  • "Set up notification rules for threshold alerts"
  • "Manage billing invoices"
  • "Install the Stripe marketplace app"
  • Debugging metering, billing, or subscription lifecycle

Resources

Official API Tags

The OpenMeter API organizes endpoints into these 15 tags:

#TagDescription
1AppsManage app integrations (list, get, update, uninstall)
2App: Custom InvoicingInterface third-party invoicing and payment systems
3App: StripeStripe billing support (API key, webhook, checkout)
4BillingBilling profiles, invoices, customer overrides, pending lines
5CustomersCustomer lifecycle, app data, Stripe linking, entitlement values
6DebugInternal metrics (Prometheus format)
7EntitlementsUsage limits, quota-based pricing, feature access
8EventsCloudEvents ingestion and listing
9Lookup InformationStatic data (currencies, progress)
10MetersAggregation rules, usage queries, group-by
11NotificationsChannels, rules, events for threshold alerts
12PortalConsumer-facing usage dashboards via scoped tokens
13Product CatalogPlans, features, addons (versioning, rate cards, publish lifecycle)
14SubjectsDeprecated — use Customers with usageAttribution.subjectKeys
15SubscriptionsCustomer plan assignments, cancel, change, migrate, restore

Base URL and Auth

  • Base URL: OPENMETER_URL (e.g. http://localhost:8888 for local, or your deployed URL)
  • Auth: Authorization: Bearer <OPENMETER_API_KEY>. Local self-hosted often runs unauthenticated.
  • Content-Type: application/json for most endpoints; application/cloudevents+json for POST /api/v1/events

Concepts

Meter (aggregates events) → Feature (metered entitlement) → Plan (limits + pricing)
                                                                    ↓
Customer (subject keys) ←→ Subscription (customer + plan = active entitlements)
                                    ↓
                              Billing Profile → Invoices (via Stripe/Sandbox/Custom App)
  • Meter: Aggregation rule for events (COUNT, SUM, etc.). Events reference a meter via type matching eventType.
  • Feature: Tied to a meter or boolean; used in plan rate cards for quotas and overage.
  • Plan: Contains phases and rate cards. Part of the Product Catalog alongside Features and Addons.
  • Addon: Modular rate card bundle, attachable to plans or subscriptions.
  • Customer: Has usageAttribution.subjectKeys; event subject must match for usage to attach.
  • Subscription: Links customer to plan; active subscription grants entitlements.
  • Entitlement: Per-customer access to a feature with usage tracking and limits.
  • Grant: One-time credit or usage allocation against an entitlement.
  • Notification: Automated alert when entitlement thresholds are reached.
  • App: Billing provider integration (Stripe, Sandbox, Custom Invoicing).

1. Events

Ingest: POST /api/v1/events | Content-Type: application/cloudevents+json

{
  "specversion": "1.0",
  "id": "unique-event-id",
  "type": "api_request",
  "source": "my-app",
  "subject": "user_abc123",
  "time": "2026-02-14T12:00:00Z",
  "data": { "value": 1, "path": "/v1/events", "method": "GET" }
}
FieldRequiredNotes
typeYesMust match meter's eventType
subjectYesMust match customer's usageAttribution.subjectKeys
sourceYesIdentifies the producing system
idYesIdempotency key (deduplication within 24h)
timeRecommendedISO 8601 timestamp
dataRecommendedArbitrary payload; meters use $.path for groupBy

List events: GET /api/v1/events?from=...&to=...&subject=...&hasError=...


2. Meters

OperationMethodPath
ListGET/api/v1/meters
CreatePOST/api/v1/meters
GetGET/api/v1/meters/{meterIdOrSlug}
UpdatePUT/api/v1/meters/{meterIdOrSlug}
DeleteDELETE/api/v1/meters/{meterIdOrSlug}
Query usageGET/api/v1/meters/{meterIdOrSlug}/query?subject=...&from=...&to=...&windowSize=HOUR
Query (POST)POST/api/v1/meters/{meterIdOrSlug}/query
Group-by valuesGET/api/v1/meters/{meterIdOrSlug}/group-by/{groupBy}/values
List subjectsGET/api/v1/meters/{meterIdOrSlug}/subjects

Aggregation types: COUNT, SUM, AVG, MIN, MAX, UNIQUE_COUNT

Window sizes: MINUTE, HOUR, DAY, MONTH


3. Product Catalog

Plans, Features, and Addons all live under this tag. See references/product-catalog.md for versioning lifecycle, rate cards, and detailed examples.

Features

OperationMethodPath
ListGET/api/v1/features
CreatePOST/api/v1/features
GetGET/api/v1/features/{featureId}
DeleteDELETE/api/v1/features/{featureId}

Plans

OperationMethodPath
ListGET/api/v1/plans
CreatePOST/api/v1/plans
GetGET/api/v1/plans/{planIdOrKey}
UpdatePUT/api/v1/plans/{planIdOrKey}
DeleteDELETE/api/v1/plans/{planIdOrKey}
Next versionPOST/api/v1/plans/{planIdOrKey}/next
PublishPOST/api/v1/plans/{planIdOrKey}/publish
ArchivePOST/api/v1/plans/{planIdOrKey}/archive
Plan AddonsCRUD/api/v1/plans/{planIdOrKey}/addons/...

Addons

OperationMethodPath
ListGET/api/v1/addons
CreatePOST/api/v1/addons
GetGET/api/v1/addons/{addonIdOrKey}
UpdatePUT/api/v1/addons/{addonIdOrKey}
DeleteDELETE/api/v1/addons/{addonIdOrKey}
PublishPOST/api/v1/addons/{addonIdOrKey}/publish
ArchivePOST/api/v1/addons/{addonIdOrKey}/archive

Critical: Plan/addon keys must be snake_case (^[a-z0-9]+(?:_[a-z0-9]+)*$). Rate card upToAmount must be a string. Subscription creation uses plan: {"key": "plan_key"}, not a raw planId. Plans follow a draft -> published -> archived lifecycle.


4. Customers

OperationMethodPath
ListGET/api/v1/customers?page=...&pageSize=...&subject=...&planKey=...
CreatePOST/api/v1/customers
GetGET/api/v1/customers/{customerIdOrKey}
DeleteDELETE/api/v1/customers/{id}
Get accessGET/api/v1/customers/{id}/access
SubscriptionsGET/api/v1/customers/{id}/subscriptions
Entitlement valueGET/api/v1/customers/{id}/entitlements/{featureKey}/value
Stripe dataGET/PUT/api/v1/customers/{id}/stripe
Stripe portalPOST/api/v1/customers/{id}/stripe/portal
App dataGET/PUT/DELETE/api/v1/customers/{id}/apps/{appIdOrType}

Gotcha: DELETE returns 409 if customer has active subscriptions or non-final invoices. See references/billing.md for the customer delete flow.


5. Subscriptions

OperationMethodPath
CreatePOST/api/v1/subscriptions
GetGET/api/v1/subscriptions/{id}
EditPATCH/api/v1/subscriptions/{id}
DeleteDELETE/api/v1/subscriptions/{id}
CancelPOST/api/v1/subscriptions/{id}/cancel
Change planPOST/api/v1/subscriptions/{id}/change
MigratePOST/api/v1/subscriptions/{id}/migrate
RestorePOST/api/v1/subscriptions/{id}/restore
Unschedule cancelPOST/api/v1/subscriptions/{id}/unschedule-cancelation
Subscription addonsGET/POST/api/v1/subscriptions/{id}/addons

PATCH Subscription Customizations

The PATCH /api/v1/subscriptions/{id} endpoint supports a customizations array for modifying subscription items without changing plans. This is useful for admin operations like adding bonus quota.

Request body:

{
  "customizations": [
    {
      "op": "add_item",
      "path": "/phases/0/items/{featureKey}",
      "value": {
        "createInput": {
          "type": "boolean" | "static" | "metered",
          "issueAfterReset": 55000,
          "isSoftLimit": false
        }
      }
    }
  ]
}

Use cases:

  • Add quota bonus: Increase issueAfterReset to give extra API calls for the current period
  • Revert quota: Reset issueAfterReset to plan base value at period end

Key fields:

FieldDescription
opOperation type: add_item, remove_item
pathJSONPath to the item, e.g. /phases/0/items/api_requests
value.createInput.issueAfterResetQuota issued at start of each period
value.createInput.isSoftLimitfalse = hard limit, true = overage allowed

Response includes:

  • items[].entitlement.currentUsagePeriod — Start/end of current billing period
  • items[].entitlement.issueAfterReset — Updated quota value

Verified behavior: When issueAfterReset is modified via PATCH, the change is immediately reflected in totalAvailableGrantAmount balance without requiring a period reset.

stretch_phase Operation

The stretch_phase operation extends a subscription phase duration without affecting quota periods. Useful for trial extensions.

Request body:

{
  "customizations": [
    {
      "op": "stretch_phase",
      "phaseKey": "trial",
      "extendBy": "P7D"
    }
  ]
}

Critical: Phase key must match exactly. The phaseKey must match the subscription's actual phase key:

# Check subscription's phase keys first
curl http://localhost:8888/api/v1/subscriptions/{id} | jq '.phases[].key'

Common pitfall: If you update your plan to have different phase keys (e.g., changing from "standard" to "trial"), existing subscriptions retain their original phase keys. The stretch_phase operation will fail with a 400 error if the phase key doesn't exist.

Subscription State Limitations

StatusAllowed Operations
activePATCH, cancel, change, migrate
inactiveNone (must create new subscription)
canceledrestore, then other operations

Key insight: Inactive subscriptions (e.g., ended trials) cannot be modified. To "reactivate" an expired trial, create a new subscription on the current plan version.

Legacy Subscription Migration Pattern

When plan versions change (e.g., adding new phases), existing subscriptions are NOT automatically migrated. For admin tools that modify subscriptions:

const omStatus = await getSubscriptionStatus(subscriptionId);

if (omStatus.status === "inactive" || omStatus.phaseKey !== expectedPhaseKey) {
  // Create new subscription on current plan version
  const newSub = await createSubscription(customerId, planKey);
  // Update local DB with new OpenMeter subscription ID
} else {
  // Use normal modification (stretch_phase, add_item, etc.)
  await patchSubscription(subscriptionId, customizations);
}

6. Entitlements

OperationMethodPath
List allGET/api/v1/entitlements
Get by idGET/api/v1/entitlements/{id}
Per-customer valueGET/api/v1/customers/{id}/entitlements/{featureKey}/value
HistoryGET/api/v1/subjects/{subjectIdOrKey}/entitlements/{idOrKey}/history
Reset usagePOST/api/v1/subjects/{subjectIdOrKey}/entitlements/{id}/reset
OverridePUT/api/v1/subjects/{subjectIdOrKey}/entitlements/{idOrKey}/override
GrantsPOST/GET/DELETE/api/v1/subjects/.../entitlements/.../grants, /api/v1/grants/...

7. Billing

See references/billing.md for invoice lifecycle, customer delete flow, and rate card schemas.

ResourceOperationsBase Path
ProfilesList, Create, Get, Update, Delete/api/v1/billing/profiles
Customer overridesList, Upsert, Get, Delete/api/v1/billing/profiles/{id}/customer-overrides
InvoicesList, Get, Update, Delete, Simulate/api/v1/billing/invoices
Invoice actionsAdvance, Approve, Retry, Void, Snapshot, Recalculate taxPOST on /api/v1/billing/invoices/{id}/{action}
Pending linesCreate, Invoice/api/v1/billing/customers/{id}/invoices/pending-lines

Invoice lifecycle: gathering → draft → issuing → issued → (paid | void | uncollectible)


8. Notifications

See references/notifications.md for channels, rules, and event details.

ResourceOperationsBase Path
ChannelsList, Create, Get, Update, Delete/api/v1/notification/channels
RulesList, Create, Get, Update, Delete, Test/api/v1/notification/rules
EventsList, Get, Resend/api/v1/notification/events

Note: Channel creation via API is Cloud-only (Svix-backed). Self-hosted uses YAML config.


9. Apps

OperationMethodPath
List appsGET/api/v1/apps
Get appGET/api/v1/apps/{id}
Update appPUT/api/v1/apps/{id}
UninstallDELETE/api/v1/apps/{id}

App: Stripe

OperationMethodPath
Update Stripe keyPUT/api/v1/apps/{id}/stripe/api-key
Stripe webhookPOST/api/v1/apps/{id}/stripe/webhook
Checkout sessionPOST/api/v1/stripe/checkout/sessions

App: Custom Invoicing

OperationMethodPath
Draft syncedPOST/api/v1/apps/{id}/custom-invoicing/draft-synchronized
Issuing syncedPOST/api/v1/apps/{id}/custom-invoicing/issuing-synchronized
Update paymentPOST/api/v1/apps/{id}/custom-invoicing/update-payment-status

Marketplace

OperationMethodPath
List listingsGET/api/v1/marketplace/listings
Get listingGET/api/v1/marketplace/listings/{type}
Install (generic)POST/api/v1/marketplace/listings/{type}/install
Install (API key)POST/api/v1/marketplace/listings/{type}/install/apikey
Install (OAuth2 URL)GET/api/v1/marketplace/listings/{type}/install/oauth2
Install (OAuth2 auth)POST/api/v1/marketplace/listings/{type}/install/oauth2/authorize

10. Portal

OperationMethodPath
Create tokenPOST/api/v1/portal/tokens
List tokensGET/api/v1/portal/tokens
Invalidate tokensPOST/api/v1/portal/tokens/invalidate
Query meterGET/api/v1/portal/meters/{meterSlug}/query

11. Lookup Information

OperationMethodPath
List currenciesGET/api/v1/currencies
Get progressGET/api/v1/progress

12. Debug

OperationMethodPath
Get metricsGET/api/v1/debug/metrics

13. Subjects (Deprecated)

Use Customers with usageAttribution.subjectKeys instead.

OperationMethodPath
ListGET/api/v1/subjects
UpsertPOST/api/v1/subjects
GetGET/api/v1/subjects/{subjectIdOrKey}
DeleteDELETE/api/v1/subjects/{subjectIdOrKey}

Gotchas and Errors

SymptomCauseFix
409 on DELETE customerActive subscriptions or non-final invoicesCancel subs, void/delete invoices first
400 "single draft version"Duplicate plan draftSkip creation if plan key exists
400 "only Plans in [draft scheduled] can be published"Plan already activeExpected — skip publish
500 on POST /notification/channelsSelf-hosted: not implementedUse YAML config for local; API for Cloud only
405 on PATCH invoicePATCH not supportedUse POST subpaths: /advance, /approve, /void
Usage not attributedSubject mismatchEvent subject must match usageAttribution.subjectKeys
Plan not foundWrong key formatUse snake_case: pro, pro_plus
Event not meteredType mismatchEvent type must equal meter's eventType
Overage not billedTier formatupToAmount must be string; include both flatPrice and unitPrice
IDs look like 01G65Z...ULID formatStandard; regex: ^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$

Self-Hosted Troubleshooting: Railway/Kafka

Events Not Metering (0 Usage, Empty /api/v1/events)

Root Cause: Kafka has no persistent volume. Topics are lost on every Kafka restart.

Symptoms:

  • OpenMeter logs: kafka delivery failed: Broker: Unknown topic or partition
  • Sink worker logs: no topics found to be subscribed to or partitions=[]
  • ClickHouse has 0 tables
  • /api/v1/events returns []

Architecture:

Event → OpenMeter API → Kafka → Sink Worker → ClickHouse → Meters

If any link breaks, events don't meter.

Fix:

  1. Add Kafka volume at /var/lib/kafka/data

- Railway: Service → Settings → Volumes → Add - For Confluent images: Set RAILWAY_RUN_UID=0 for volume permissions

  1. Provision topics explicitly (if KAFKA_AUTO_CREATE_TOPICS_ENABLE=false): om_default_events (namespace events - sink worker consumes) om_sys.api_events om_sys.ingest_events
  2. Restart OpenMeter + sink-worker after Kafka restarts to refresh metadata
  3. Verify:

- Restart Kafka twice → topics persist - Send test event → appears in /api/v1/events

Kafka Environment Variables (Railway):

KAFKA_AUTO_CREATE_TOPICS_ENABLE=true  # Or provision topics explicitly
KAFKA_LOG_DIRS=/var/lib/kafka/data/logs-v2  # Use subdirectory if cluster ID conflicts
RAILWAY_RUN_UID=0  # Confluent images need root for volume permissions

Sink Worker Partition Instability

Symptom: Sink worker gets partition assignment, loses it within seconds.

Cause: Multiple sink-worker instances competing for single partition (Railway rolling deploys).

Fix: Ensure only 1 sink-worker instance runs. Check Kafka logs for "group... with N members" where N > 1.


References

First-Party Documentation

SDKs

Related Skills

Reference

The full OpenAPI 3.0 spec is bundled at assets/openapi-spec.json. Use it as the source of truth for request/response schemas, query parameters, and error codes.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

34.5%
按下载量换算33

Claude

30.03%
按下载量换算29

Cursor

18.52%
按下载量换算18

Gemini CLI

9.2%
按下载量换算9

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills