Cloudflare AI Gateway adds control over payload logging with new header
Selective Payload Logging for AI Gateway
Cloudflare AI Gateway has added a new cf-aig-collect-log-payload header that gives developers granular control over what data is persisted in logs.
What Changed
The new header allows you to:
- Keep logging enabled (default behavior with
true): Store request and response bodies alongside metadata - Skip payload storage (set to
false): Log metadata only while omitting sensitive prompt and response content
What Gets Logged with false
When you disable payload storage, AI Gateway still captures valuable observability data:
- Token counts (input and output)
- Model name and provider
- HTTP status codes
- Request cost
- Request duration
Use Cases
This feature is particularly useful when:
- You need usage metrics and cost tracking but don't want to persist sensitive user queries
- Compliance requirements restrict storing prompt data
- You're working with PII or confidential information in requests
Implementation
Simply add the header to your API requests:
curl https://gateway.ai.cloudflare.com/v1/$ACCOUNT_ID/$GATEWAY_ID/openai/chat/completions \
--header "cf-aig-collect-log-payload: false"
For additional details, see the Logging documentation.