Cloudflare AI Gateway adds header to disable payload logging while preserving metrics
Privacy-Focused Logging Control
Cloudflare AI Gateway now supports the cf-aig-collect-log-payload header, giving developers granular control over what data gets stored in logs. By default, the header is set to true and both payloads and metadata are logged. Setting this header to false skips payload storage entirely while preserving critical usage metrics.
What Still Gets Logged
When you disable payload logging, AI Gateway continues to capture:
- Token counts – Track usage patterns and costs
- Model and provider information – Monitor which models are being used
- Status codes and response metadata – Troubleshoot errors
- Cost data – Calculate billing and resource consumption
- Duration metrics – Monitor latency and performance
Use Cases
This feature is especially valuable for teams handling sensitive data:
- PII-heavy applications – Log usage without persisting email addresses, phone numbers, or other personal information
- Compliance requirements – Meet data minimization standards while maintaining observability
- Cost tracking – Monitor spending without storing the actual prompts or responses
Implementation
Simply add the header to your AI Gateway requests:
curl https://gateway.ai.cloudflare.com/v1/$ACCOUNT_ID/$GATEWAY_ID/openai/chat/completions \
--header "Authorization: Bearer $TOKEN" \
--header 'Content-Type: application/json' \
--header 'cf-aig-collect-log-payload: false' \
--data '{"model": "gpt-4o-mini", "messages": [...]}'
For full details on logging capabilities, see the Logging documentation.