AI Gateway Authentication Failed (401 Unauthorized)

What is the name of the modal you’re running?

AI Gateway

What is the error number?

401 Unauthorized

What is the error message?

AI Gateway Authentication Failed

What is the issue or error you’re encountering

AI Gateway Authentication Failed

What steps have you taken to resolve the issue?

We set up an AI Gateway with authentication, and it had been working fine for the past 20 days. However, about two hours ago (Apr 1, 2025, 6:24:55 PM), we started seeing 401 Unauthorized errors. Disabling the Authenticated Gateway settings made the gateway work again.

I tried generating a new token and re-enabling authentication, but it still failed. For now, I’ve turned off authentication as a workaround, but there may be an issue with the Authenticated Gateway.

We’re seeing the same, working great for many weeks, broken today.

Specifically a request like this:

 curl -X POST "https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_name}/google-ai-studio/v1beta/models/text-embedding-004:batchEmbedContents" \
 -H "Content-Type: application/json" \
 -H "x-goog-api-key: XXX" \
 -H "cf-aig-authorization: Bearer KNOWN_WORKING_TOKEN" \
 -H "cf-aig-collect-log: false" \
 -d '{"requests":[{"model":"models/text-embedding-004","content":{"role":"user","parts":[{"text":"!!"}]},"outputDimensionality":768}]}'

Ends up with: {"success":false,"result":[],"messages":[],"error":[{"code":2009,"message":"Unauthorized"}]}

However, a request like this succeeds:

curl -X POST "https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_name}/openai/chat/completions" \
  --header 'cf-aig-authorization: Bearer KNOWN_WORKING_TOKEN' \
  --header 'Authorization: Bearer XXX' \
  --header 'Content-Type: application/json' \
  --data '{"model": "gpt-3.5-turbo", "messages": [{"role": "user", "content": "What is Cloudflare?"}]}'

Indicating it isn’t completely broken - maybe something up with the Google AI Studio Provider ?

Cross posting here from Discord:

I can confirm this across 2 separate ENT accounts, hitting azure openai, google ai studio, and workers ai (any model). Confirmed by bypassing ai gateway to hit azure directly (no request change) and it works. Last known good request was 2025-04-01T18:24:00Z

Update 2025-04-01T22:42:00Z: This has been internally escalated.

Update 2025-04-01T23:40:00Z: Public status page now up Authentication Errors on AI Gateway

2 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.