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

Standardize access via LiteLLM #53

Closed
345ishaan opened this issue Dec 27, 2024 · 1 comment
Closed

Standardize access via LiteLLM #53

345ishaan opened this issue Dec 27, 2024 · 1 comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@345ishaan
Copy link

345ishaan commented Dec 27, 2024

I want to try out latest Gemini models and seems like there are two ways to access them.

  1. Google AI API
  2. Vertex AI API

I think I created my API key using the 1) and when i run:

from litellm import completion
import os

os.environ['GEMINI_API_KEY'] = ""
response = completion(
    model="gemini-1.5-flash", 
    messages=[{"role": "user", "content": "write code for saying hi from LiteLLM"}]
)

I get the following error:

APIConnectionError: litellm.APIConnectionError: Your default credentials were not found. To set up Application Default Credentials, see https://cloud.google.com/docs/authentication/external/set-up-adc for more information.

I am able to use my API key though if i run like this:

import google.generativeai as google_genai


google_genai.configure(api_key="")

llm = google_genai.GenerativeModel("gemini-1.5-flash")
response = llm.generate_content(["write code for saying hi from LiteLLM"])
@345ishaan 345ishaan added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Dec 27, 2024
@sasha-gitg sasha-gitg added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. and removed type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Jan 8, 2025
@holtskinner
Copy link
Member

Ok, you are using Google AI Studio (Also known as the Gemini Developer API).

And the LiteLLM documentation shows this code to use that API.

from litellm import completion
import os

os.environ['GEMINI_API_KEY'] = ""
response = completion(
    model="gemini/gemini-pro", 
    messages=[{"role": "user", "content": "write code for saying hi from LiteLLM"}]
)

Yours is slightly different, you don't have the gemini/ prefix to your model name.

If you have further issues with LiteLLM, I recommend filing an issue in their repository here: https://github.com/BerriAI/litellm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

3 participants