Skip to content

Commit

Permalink
Added collect log code example
Browse files Browse the repository at this point in the history
  • Loading branch information
daisyfaithauma committed Sep 23, 2024
1 parent af0e807 commit ce6722f
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/content/docs/ai-gateway/observability/logging.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,25 @@ If you turn off logging and are using Logpush, this will prevent the response an

To override the default logging behavior set in the settings tab, you can define headers on a per-request basis.

## Collect logs (collect_logs)
## Collect logs (cf-aig-collect-log)

The `collect_logs` header allows you to bypass the default log setting for the gateway. If the gateway is configured to save logs, the header will exclude the user prompt and model response data for that specific request. Conversely, if logging is disabled at the gateway level, this header will save the user prompt and model response data for that request.
The `cf-aig-collect-log` header allows you to bypass the default log setting for the gateway. If the gateway is configured to save logs, the header will exclude the user prompt and model response data for that specific request. Conversely, if logging is disabled at the gateway level, this header will save the user prompt and model response data for that request.

In this example, the gateway is configured to save logs, however we do not want this specific request to save the user prompt and model response.

```bash
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: false \
--data ' {
"model": "gpt-4o-mini",
"messages": [
{
"role": "user",
"content": "What is the email address and phone number of user123?"
}
]
}
'
```

0 comments on commit ce6722f

Please sign in to comment.