Skip to content

User location is not supported for the API use #587

Closed as not planned
Closed as not planned
@lmyslinski

Description

@lmyslinski

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.

Metadata

Metadata

Assignees

Labels

component:apiIssues related to the API, not the SDK.type:bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions