generative-ai-js icon indicating copy to clipboard operation
generative-ai-js copied to clipboard

Region Blocked Cloudflare Workers

Open fahreziadh opened this issue 1 year ago • 1 comments

Description of the bug:

So, i tried deploy my code to cloudflare workers and I got error response.

i don't know why, because when I try run my code on my local machine it works really well.

(error) { name: 'AI_APICallError', message: 'User location is not supported for the API use.', url: 'https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash-latest:generateContent', requestBodyValues: { generationConfig: { temperature: 0 }, contents: [ [Object], [Object], [Object] ] }, statusCode: 400, responseHeaders: { 'alt-svc': 'h3=":443"; ma=2592000,h3-29=":443"; ma=2592000', 'cache-control': 'private', 'cf-cache-status': 'DYNAMIC', 'cf-ray': '88958fc801afb458-HKG', connection: 'keep-alive', 'content-type': 'application/json; charset=UTF-8', date: 'Sat, 25 May 2024 12:34:48 GMT', server: 'cloudflare', 'server-timing': 'gfet4t7; dur=322', 'transfer-encoding': 'chunked', vary: 'Origin, X-Origin, Referer', 'x-content-type-options': 'nosniff', 'x-frame-options': 'SAMEORIGIN', 'x-xss-protection': '0' }, responseBody: '{\n' + ' "error": {\n' + ' "code": 400,\n' + ' "message": "User location is not supported for the API use.",\n' + ' "status": "FAILED_PRECONDITION"\n' + ' }\n' + '}\n', isRetryable: false, data: { error: { code: 400, message: 'User location is not supported for the API use.', status: 'FAILED_PRECONDITION' } } }

Actual vs expected behavior:

No response

Any other information you'd like to share?

No response

fahreziadh avatar May 25 '24 12:05 fahreziadh

I realize something weird, I think the issue is from Cloudflare's side.

image

I don't understand why the Gemini API access to Hong Kong region.

as far I know that cloudflare will refer to closest server that client access

fahreziadh avatar May 25 '24 12:05 fahreziadh

Just to make sure I'm understanding, it seems like the Cloudflare worker has a location of Hong Kong, which is not supported. I'm not sure if you were asking if this region is supported, or if you already know, but it doesn't seem to be: https://ai.google.dev/gemini-api/docs/available-regions

I think we can close this issue, but let me know if I've misunderstood anything and you still have any outstanding concerns.

hsubox76 avatar May 28 '24 17:05 hsubox76