Cloudflare worker blocked by openAI?

For Workers & Pages, what is the name of the domain?

jeff-mybusiness.workers.dev

What is the error number?

Error 403 from openAI

What is the error message?

“OpenAI API Response: { “error”: { “code”: “unsupported_country_region_territory”, “message”: “Country, region, or territory not supported”, “param”: null, “type”: “request_forbidden” } }”,

What is the issue or error you’re encountering

The detected country is Vietnam, which shouldn’t be block by openAI but it has shown as blocked. Just happened starting today

1 Like


Screenshot to show issue.

1 Like

You might try Smart Placement to get your Worker to make its requests from somewhere else.

Tried this approach but still getting the same error.

{
“error”: true,
“url”: “https://my-app/api/generate/message”,
“statusCode”: 500,
“statusMessage”: “Internal Server Error”,
“message”: “403 Country, region, or territory not supported”
}

Could be a geographical issue and I’m closer to a unsupported region.
Any other way I can select my host but still remain free?

1 Like

I am facing the same issue, country of orgin from singapore but when sent to cloudflare worker it routes to HKG server which gets blocked by Openai

Yeah that doesn’t solve the issue and I’m forced to redirect my worker to another edge function so that the request to openai will go through another region. But that means Cloudflare worker is now redundant and can be gotten rid in my next app update.
Hope that Cloudflare can look into this as AI is getting more and more common while their HK server is now doing more harm to it than good.

1 Like

How can solve this problem?
I had same problem

I’m having exact same issue, for Anthropic and Google (gemini) as well.

Thinking of using Durable Objects as a workaround, but this should be fixed ASAP for AI Gateway.

Make sure your country is in allowed API list

If you’re on Cloudflare free plans and in some Asian countries, you maybe routed through Cloudflare Datacenters not in the allowed country lists i.e. Hong Kong. Cloudflare Business or higher paid plans would have more probability of not being routed through such countries but no real guarantee unless on Cloudflare Enterprise plans.

So if using Cloudflare non-enterprise or free plans, try using openrouter.ai instead to access your desired LLM model. Works with Cloudflare AI Gateway OpenRouter · Cloudflare AI Gateway docs and Cloudflare Workers

I use Cloudflare Workers/AI Gateway with Openrouter AI to get access to Claude, Gemini, OpenAI and 300+ other LLM models Models | OpenRouter all via OpenRouter’s OpenAI API compatible endpoint OpenRouter Quickstart Guide | Developer Documentation | OpenRouter | Documentation. Why limit yourself just to OpenAI LLM models, when you can access 300+ of them :smiley:

Have tried, openrouter still gets region error when provider is openai, Smart placements does not work too. Seems like there is no solution to this as long as colo is from HK.

Unless we can restrict certain colo HK and restricted areas, Will be cancelling my cloudflare worker plan

I had the same problem, and ended up implementing a proxy server.