Skip to content

AI Gateway

AI Gateway is Cloudflare’s proxy in front of model providers. Every call passes through one endpoint that caches repeated requests, retries transient failures, applies rate limits and records what was spent. As a block it lets one flow reach several providers without holding one integration per provider.

What it means

A gateway sits between the application and the model so the cross-cutting concerns live in one place: a cache hit costs nothing, a 503 is retried without the flow knowing, and usage is attributed per request rather than reconstructed from provider invoices at the end of the month.

How SwiftTune uses it

The AI Gateway block carries the provider, the model and the retry policy as configuration, so switching provider is an edit on the canvas. Prompts are assembled with the shared prefix first and the variable part last, which is what lets provider-side prompt caching actually hit on the second call.

Primary sources