Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User location is not supported for the API use #587

Open
lmyslinski opened this issue Oct 5, 2024 · 6 comments
Open

User location is not supported for the API use #587

lmyslinski opened this issue Oct 5, 2024 · 6 comments
Assignees
Labels
component:python sdk Issue/PR related to Python SDK status:triaged Issue/PR triaged to the corresponding sub-team type:bug Something isn't working

Comments

@lmyslinski
Copy link

lmyslinski commented Oct 5, 2024

Description of the bug:

My production just went down out of the blue, after 2 weeks since integrating Gemini.

Actual vs expected behavior:

No response

Any other information you'd like to share?

I'm currently on the Pay-as-you-go plan.

pyproject.toml:

google-generativeai = "^0.8.1"

I'm using the most basic config:

import google.generativeai as genai

genai.configure(api_key=os.environ["GOOGLE_AI_KEY"])

model = genai.GenerativeModel(
    model_name="gemini-1.5-flash",
    system_instruction="...",
)

file = genai.upload_file(path=file_path, display_name=file_name)

Stack trace:

ResumableUploadError: <HttpError 400 when requesting None returned "User location is not supported for the API use.". Details: "User location is not supported for the API use.">
  File "starlette/applications.py", line 122, in __call__
    await self.middleware_stack(scope, receive, send)
  File "starlette/middleware/errors.py", line 184, in __call__
    raise exc
  File "starlette/middleware/errors.py", line 162, in __call__
    await self.app(scope, receive, _send)
  File "starlette/middleware/base.py", line 108, in __call__
    response = await self.dispatch_func(request, call_next)
  File "main.py", line 60, in logging_middleware
    response: Response = await call_next(request)
  File "starlette/middleware/base.py", line 84, in call_next
    raise app_exc
  File "starlette/middleware/base.py", line 70, in coro
    await self.app(scope, receive_or_disconnect, send_no_error)
  File "starlette/middleware/cors.py", line 83, in __call__
    await self.app(scope, receive, send)
  File "starlette/middleware/exceptions.py", line 79, in __call__
    raise exc
  File "starlette/middleware/exceptions.py", line 68, in __call__
    await self.app(scope, receive, sender)
  File "fastapi/middleware/asyncexitstack.py", line 20, in __call__
    raise e
  File "fastapi/middleware/asyncexitstack.py", line 17, in __call__
    await self.app(scope, receive, send)
  File "starlette/routing.py", line 718, in __call__
    await route.handle(scope, receive, send)
  File "starlette/routing.py", line 276, in handle
    await self.app(scope, receive, send)
  File "starlette/routing.py", line 66, in app
    response = await func(request)
  File "fastapi/routing.py", line 274, in app
    raw_response = await run_endpoint_function(
  File "fastapi/routing.py", line 191, in run_endpoint_function
    return await dependant.call(**values)
    (app stack omitted)
        file = genai.upload_file(path=file_path, display_name=file_name)
  File "/app/.venv/lib/python3.11/site-packages/google/generativeai/files.py", line 71, in upload_file
    response = client.create_file(
  File "/app/.venv/lib/python3.11/site-packages/google/generativeai/client.py", line 114, in create_file
    result = request.execute()
  File "googleapiclient/_helpers.py", line 130, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "googleapiclient/http.py", line 902, in execute
    _, body = self.next_chunk(http=http, num_retries=num_retries)
  File "googleapiclient/_helpers.py", line 130, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "googleapiclient/http.py", line 1022, in next_chunk
    raise ResumableUploadError(resp, content)

My servers are located in Warsaw. I can successfully run from localhost also from Poland, but all of my prod requests are failing.

@lmyslinski
Copy link
Author

lmyslinski commented Oct 5, 2024

I was able to workaround the problem by moving my servers to Sweden. Still, I cannot depend service that can just randomly start denying my requests. The issue has been ongoing for 6 hours (and still is) until I was able to get down to "fix" it (it's a weekend after all)

@gmKeshari gmKeshari added type:bug Something isn't working status:triaged Issue/PR triaged to the corresponding sub-team component:python sdk Issue/PR related to Python SDK labels Oct 7, 2024
@Alexmalab
Copy link

If it supports proxy configuration, you can try routing it through the Sweden network.

@vTuanpham
Copy link

+1 having the same problem, hoping a fix is coming

@vTuanpham
Copy link

Current workaround seem to be VPN or just simply switch the VM location.

@WoWnik
Copy link

WoWnik commented Nov 20, 2024

My server in Finland also started getting error 400. After moving to the Polish server everything was fine. But within 2 weeks I started getting error 400. After two weeks the error disappeared. And after another two weeks it appeared again.

It seems Google blocks requests from certain IP addresses, then unblocks them, and everything starts all over again. Why and for what reason?

@krzynio
Copy link

krzynio commented Dec 6, 2024

Hello, same here.

In our case the issue was that Google disabled access from Hetzner via IPv4.

If you have to use IPv4 - for example in docker environment, you can setup a proxy (I used squid) with dns configuration:

dns_nameservers 2001:4860:4860::8888 2001:4860:4860::8844 # Google IPv6 DNS

and use env vars in container:

curl

google.generativeai

(or another IP address where the proxy is running)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:python sdk Issue/PR related to Python SDK status:triaged Issue/PR triaged to the corresponding sub-team type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants