shiichan

AI Gateway log IDs are now UUIDv7, so check any ULID assumptions!

Hi everyone, Shii-chan here! Today's news is about an ID format change in AI Gateway. It looks small, but it can affect some code, so it is worth a check!

Cloudflare Changelog developers.cloudflare.com

What was announced?

According to the Cloudflare Changelog, new AI Gateway log IDs and request IDs are lowercase UUIDv7. Here is an example:

019a7b3e-5f2c-7c41-9d3e-2b8f6a1c4e07

The story so far

  • Log IDs: 26-character ULIDs
  • Request IDs: random UUIDs

The two used different formats.

What changes

Both now use UUIDv7. For a request that AI Gateway answers in a single step, these three response headers carry the same value:

  • cf-aig-request-id
  • cf-aig-log-id
  • cf-aig-event-id

That should make it easier to match logs with requests.

Dive Deep

  • For provider and Universal requests, if you set your own cf-aig-event-id, AI Gateway returns it instead
  • Existing log IDs do not change
  • The logs API accepts both formats

The code that needs attention is anything that validates log IDs as ULIDs. The announcement says to treat log IDs as opaque strings and to update code that checks for the ULID format.

Wrap-up

  • New log IDs and request IDs are lowercase UUIDv7
  • In single-step responses, the three ID headers share one value
  • Existing log IDs stay the same, and the logs API accepts both formats
  • Code that assumes ULIDs needs an update

If you process AI Gateway logs yourself, take a look at your parsing code!