Cloudflare AI Gateway Integration
Cloudflare AI Gateway provides caching, rate limiting, and observability for AI API calls. LangGuard integrates with Cloudflare AI Gateway to import request logs and metrics.
Overview
The Cloudflare AI Gateway integration enables LangGuard to:
- Import AI request logs from your Cloudflare AI Gateway
- Track model usage and costs across providers
- Monitor latency and error rates for gateway traffic
- Apply governance policies to captured interactions
Prerequisites
- A Cloudflare account with AI Gateway enabled
- Cloudflare Account ID
- Cloudflare API Token with AI Gateway read permissions
- LangGuard admin role
Setup
Step 1: Get Your Credentials
- Log in to the Cloudflare Dashboard
- Copy your Account ID from the sidebar
- Navigate to My Profile > API Tokens
- Click Create Token
- Grant the token AI Gateway: Read permissions
- Copy the generated token
Step 2: Add Integration in LangGuard
- Navigate to Integrations in the sidebar
- Click Add Integration
- Select AI Gateways > Cloudflare
- Enter:
- Name: A friendly name (e.g., "Production Cloudflare Gateway")
- Account ID: Your Cloudflare account ID
- API Token: Your Cloudflare API token
- Click Test Connection
- Click Save
What Gets Captured
Gateway Requests
All requests flowing through your Cloudflare AI Gateway are captured:
| Field | Description |
|---|---|
| Model | The AI model called |
| Provider | The upstream provider (OpenAI, Anthropic, etc.) |
| Input/Output Tokens | Token counts |
| Latency | End-to-end response time |
| Cache Status | Whether the response was served from cache |
| Status | Success or error |
Gateway Metrics
- Cache hit rates
- Total requests and error rates
- Latency percentiles
- Rate limit events
Troubleshooting
No Data Appearing
- Verify your Account ID and API Token are correct
- Ensure traffic is flowing through your AI Gateway
- Check that the API token has AI Gateway read permissions
- Try triggering a manual sync
Authentication Failed
- Confirm the API token hasn't been revoked or expired
- Verify the token's permission scopes include AI Gateway
- Generate a new token if needed
Next Steps
- Integrations Overview — See all available integrations
- Trace Explorer — Analyze captured traces
- Monitoring — View aggregate metrics