tech/cloudflare/ai/ai-gateway

Proxy Claude, OpenAI, and Workers AI with caching and rate limiting.

1|Updated Apr 1, 2026
One-click install
npx skills add https://github.com/2nth-ai/skills --skill tech-cloudflare-ai-ai-gateway
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tech/cloudflare/ai/ai-gateway
Source: https://github.com/2nth-ai/skills/tree/main/tech/cloudflare/ai/ai-gateway
Command: npx skills add https://github.com/2nth-ai/skills --skill tech-cloudflare-ai-ai-gateway

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires tech/cloudflare/workers, tech/cloudflare/ai/workers-ai, and includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve?

This Skill provides a unified proxy for Claude, OpenAI, and Workers AI, solving issues related to token metering, caching, rate limiting, fallback routing, and token usage analytics without changing AI SDK code.

Core Features & Use Cases

  • Token Metering: Monitor and control token usage across all AI calls.
  • Caching: Implement semantic caching to reduce duplicate AI costs.
  • Rate Limiting: Set rate limits on AI usage per client or user.
  • Fallback Routing: Fallback to Workers AI if Claude fails.
  • Observability: Track token usage, latency, and cost across all AI calls in one dashboard.
  • Token Economy: Implement the 2nth token economy for per-client billing via gateway logs.
  • Use Case: For a financial institution, this Skill can help manage API costs by caching common queries and setting per-user limits.

Quick Start

Set up an AI Gateway in the Cloudflare dashboard and replace the Anthropic base URL in your Worker with the gateway URL.

Frequently Asked Questions about tech/cloudflare/ai/ai-gateway

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I route Claude and OpenAI requests through a single proxy?

Route Claude and OpenAI requests through a single proxy by setting up a Cloudflare AI Gateway and replacing the Anthropic base URL in your Worker with the gateway URL. This provides unified proxy access without changing existing AI SDK code.

What is the best way to cache AI API responses and reduce token costs?

The best way to cache AI API responses and reduce token costs is using a proxy with semantic caching. Cloudflare AI Gateway caches duplicate AI calls, significantly lowering API expenses for clients with repeated queries.

Can I set rate limits on OpenAI and Claude API calls per user?

Yes, you can set rate limits on OpenAI and Claude API calls per user. Cloudflare AI Gateway allows you to monitor and control token usage by setting specific rate limits on AI usage per client or user.

How do I implement fallback routing from Claude to Workers AI?

Implement fallback routing from Claude to Workers AI by configuring a unified proxy. Cloudflare AI Gateway automatically fallbacks to Workers AI if Claude fails, ensuring continuous AI service availability without manual intervention.

Does Cloudflare AI Gateway require SDK changes to track token usage analytics?

No, Cloudflare AI Gateway does not require SDK changes to track token usage analytics. It integrates with existing workflows and any HTTP client, providing observability for token metering, latency, and cost in one dashboard.

How do I implement per-client billing for AI token usage?

Implement per-client billing for AI token usage by applying the token economy via gateway logs. Cloudflare AI Gateway tracks token metering across all AI calls, enabling detailed per-client billing structures.