Control costs and improve quality

Last updated Apr 24, 2026 AI inference costs can grow unpredictably as your application scales, especially when using multiple providers. Cloudflare AI Gateway caches identical queries to avoid redundant inference calls, applies rate limits per user or API key, and provides unified analytics across all providers.

Solutions

AI Gateway

Cache responses, rate limit requests, and monitor usage across providers. Learn more about AI Gateway.

  • Response caching - Cache identical queries so repeated prompts do not trigger a new inference call
  • Rate limiting - Set request limits per user or Application Programming Interface (API) key to prevent abuse and control spending
  • Unified analytics - Track usage, latency, and cost across all AI providers from one dashboard

Workers Analytics Engine

Store and query time-series analytics data from Workers. Learn more about Workers Analytics Engine.

  • Custom metrics - Build AI-specific dashboards tracking tokens, latency distributions, and error rates

Get started

  1. AI Gateway get started
  2. Configure caching
  3. Workers Analytics Engine get started

Was this helpful?

YesNo

On this page

Control costs and improve quality - 图1Docs

{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/use-cases/ai/control-costs/#page","headline":"Control costs and improve quality","description":"Reduce AI inference costs and improve reliability with response caching, rate limiting, and unified provider analytics.","url":"https://developers.cloudflare.com/use-cases/ai/control-costs/","inLanguage":"en","image":"https://developers.cloudflare.com/use-cases/ai/control-costs/og.png?v=2026a75c7aea9dd5","dateModified":"2026-04-24","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}


description: Store vector embeddings, conversation history, and application state for AI applications using serverless databases and object storage. title: Store and retrieve context image: https://developers.cloudflare.com/use-cases/ai/store-and-retrieve-context/og.png?v=25deaff3c9748c29


Skip to content

Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/use-cases/llms.txt
Use this file to discover all available pages before exploring further.