Analytics and logging
Your AI Gateway dashboard shows metrics on requests, tokens, caching, errors, and cost. You can filter these metrics by time. These analytics help you understand traffic patterns, token consumption, and potential issues across AI providers. You can view the following analytics:
- Requests: Track the total number of requests processed by AI Gateway.
- Token Usage: Analyze token consumption across requests, giving insight into usage patterns.
- Costs: Gain visibility into the costs associated with using different AI providers, allowing you to track spending, manage budgets, and optimize resources.
- Errors: Monitor the number of errors across the gateway, helping to identify and troubleshoot issues.
- Cached Responses: View the percentage of responses served from cache, which can help reduce costs and improve speed.
To view analytics in the dashboard:
- Log into the Cloudflare dashboard ↗ and select your account.
- Go to AI > AI Gateway.
- Make sure you have your gateway selected.
You can use GraphQL to query your usage data outside of the AI Gateway dashboard. See the example query below. You will need to use your Cloudflare token when making the request, and change {account_id}
to match your account tag.
Your AI Gateway dashboard also shows real-time logs of individual requests, such as the prompt, response, provider, timestamps, and whether the request was successful, cached, or if there was an error. These logs now persist and can store up to 10,000 logs per gateway for better observability and analysis.