Skip to content

[BUG] cannot use gemini or vertexai #1166

@nayutah

Description

@nayutah

Describe the bug
The vertex ai or gemini ai is not properly set, the valid ways are:

async def make_aysnc_call1():
    os.environ["GEMINI_API_KEY"] = "xxxxx"

    response = await acompletion(
        model="gemini/gemini-2.5-pro",
        messages=[{"role": "user", "content": "write code for saying hi from LiteLLM"}]
    )
    print(response)
asyncio.run(make_aysnc_call1())
async def make_async_call2():
    file_path = '/Users/slc/Downloads/gen-lang-client-xxx.json'

    # Load the JSON file
    with open(file_path, 'r') as file:
        vertex_credentials = json.load(file)

    # Convert to JSON string
    vertex_credentials_json = json.dumps(vertex_credentials)

    ## COMPLETION CALL
    response = await acompletion(
        model="vertex_ai/gemini-2.5-pro",
        messages=[{ "content": "Hello, how are you?","role": "user"}],
        vertex_credentials=vertex_credentials_json
    )
    print(response)
asyncio.run(make_async_call2())

To Reproduce
Steps to reproduce the behavior:
1, enable google gemini ai
2, enter a valid your api_key
3, set api base with "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-pro"
4, set llm with 'gemini/gemini-2.5-pro' in workflow
5, start a chat and ask a question
6, got errors and exceptions

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Metadata

Metadata

Labels

StalebugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions