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

Google Gemini 1.5 pro via API access #227

Closed
haseeb-heaven opened this issue Mar 3, 2024 · 61 comments
Closed

Google Gemini 1.5 pro via API access #227

haseeb-heaven opened this issue Mar 3, 2024 · 61 comments
Assignees
Labels
component:python sdk Issue/PR related to Python SDK type:feature request New feature request/enhancement

Comments

@haseeb-heaven
Copy link

haseeb-heaven commented Mar 3, 2024

Description of the feature request:

I want to use latest version of Google Gemini-1.5-pro via API or SDK that can be integrated to our projects.

What problem are you trying to solve with this feature?

Solving the whole codebase upload media and more with 1 Million tokens limit to achieve maximum efficiency from this model.

Any other information you'd like to share?

Here is error i got

Error generating response: 404 models/gemini-1.5-pro-latest is not found for API version v1beta, or is not supported for GenerateContent. Call ListModels to see the list of available models and their supported methods.

Here is the code:

import os
import google.generativeai as genai
from dotenv import load_dotenv

def init_api_keys():
    try:
        load_dotenv()
        api_key = os.getenv("GEMINI_API_KEY")
        genai.configure(api_key=api_key)
    except Exception as exception:
        print("Error in initializing API keys:", exception)
        raise

def generate_response(prompt:str):

  # Set up the model
  generation_config = {
    "temperature": 0.1,
    "top_p": 1,
    "top_k": 1,
    "max_output_tokens": 2048,
  }
  
  model = genai.GenerativeModel(model_name="gemini-1.5-pro-latest",generation_config=generation_config)
  
  prompt_parts = [prompt]
  
  try:
    response = model.generate_content(prompt_parts)
    print(response.text)
  except Exception as exception:
    print("Error generating response:", exception)
    
if __name__ == "__main__":
    init_api_keys()
    prompt = input("> ")
    generate_response(prompt)
@haseeb-heaven haseeb-heaven added component:python sdk Issue/PR related to Python SDK type:feature request New feature request/enhancement labels Mar 3, 2024
@singhniraj08 singhniraj08 added the status:triaged Issue/PR triaged to the corresponding sub-team label Mar 7, 2024
@LindaLawton
Copy link

LindaLawton commented Mar 9, 2024

First you need to be white listed for Google Gemini-1.5-pro
If you are then you should know that Google Gemini-1.5-pro doesn't work though the Gemini api which is what this library is for.

I have heard that the api works via Google Gemini-1.5-pro going though vertex but you have to be whitelisted for that as well. I have only heard it exits I don't know anyone who managed to got into that whitelist. I haven't even heard of way of applying.

@haseeb-heaven
Copy link
Author

First you need to be white listed for Google Gemini-1.5-pro If you are then you should know that Google Gemini-1.5-pro doesnt work though the gemini api which is what this library is for.

If you do have access and really want to try Google Gemini-1.5-pro try going though vertex and use the vertex library i hear it works there.

But still in vertex-ai Gemini 1.5 pro is not available via API?

@LindaLawton
Copy link

LindaLawton commented Mar 10, 2024

@haseeb-heaven That's a completely different white list. I have only heard that it exits i don't know anyone that got access to that yet. Its not the same as the white list to access it in Google Ai Studio.

Im not even sure how to get on the Vertex ai whitelist for gemini pro 1.5

You need to test via ai studio.

@SeanTolstoyevski
Copy link

SeanTolstoyevski commented Mar 10, 2024

I can see version 1.5 in ai studio, I can selected this version. And when I examine the network panel after the prompt sending and receive response, requests are sent to google services with the 1.5 version parameter. However, when I try to access the 1.5 version via the API, I get 404, which is the error our friend received.

I think even though we are whitelisted, this does not mean that we can access the API.

@haseeb-heaven
Copy link
Author

@haseeb-heaven That's a completely different white list. I have only heard that it exits i don't know anyone that got access to that yet. Its not the same as the white list to access it in Google Ai Studio.

Im not even sure how to get on the Vertex ai whitelist for gemini pro 1.5

You need to test via ai studio.

Okay i will test via Vertex AI API but i prefer Google AI Studio API because it need only single API key for authorization.

@LindaLawton
Copy link

@SeanTolstoyevski I think you need to reread what you are white Listed for

There is NO api currently for Gemini pro 1.5 the white list only gives you access to test in Google ai studio they haven't implemented an API for it they just gave us ai studio testing

@flexchar
Copy link

I've got whitelisted on AI Studio too. Shame it's blocked in Denmark (or whole EU in that regard). If someone reverse-engineers, it feels like GPT-5 for some tasks and I am excited to integrate.

@LindaLawton do you have any idea where to find application/form for use in VertexAI?

@LindaLawton
Copy link

I have been using it from Denmark since it first came out via AI Studio start your favorite VPN and your all set. VeePN if you don't want to pay for it has a chrome extension that works. I used that before I grabbed PureVPN.

No i don't know of any one with access or I suspect its only company's directly associated with Google already. I am a GDE and they wont give me access either.

@OlegRuban-ai
Copy link

I have access to 1.5 in AIStudio, but there is no API access in version 0.4.1. Does anyone know when they plan to add it? The following packages are currently available:

models/chat-bison-001
models/text-bison-001
models/embedding-gecko-001
models/gemini-1.0-pro
models/gemini-1.0-pro-001
models/gemini-1.0-pro-latest
models/gemini-1.0-pro-vision-latest
models/gemini-pro
models/gemini-pro-vision
models/embedding-001
models/aqa

@LindaLawton
Copy link

I got access today it's comming.

@Arkm20
Copy link

Arkm20 commented Mar 19, 2024

Same here

@davidogbonnaeze
Copy link

@LindaLawton @Arkm20 , please how did you get access. i need it

@LindaLawton
Copy link

LindaLawton commented Mar 20, 2024

Im a google developer expert for ai/ml some on at google sent me a hangout message and asked for the project i wanted white listed. If GDE's are getting access its only a matter of time before the others white listed for 1.5 on ai studio get access hang in there.

Heads up the model name is gemini-1.5-pro-latest when you get access.

Any code you are using for gemini-pro will work for 1.5 as well. from what i can see

@davidogbonnaeze
Copy link

Thank you @LindaLawton

@manbeardave
Copy link

@LindaLawton are you leveraging pro-1.5 in the python SDK? or in the console?

@LindaLawton
Copy link

Im using this library to work with Gemini pro 1.5 the code is the same its just a different model. You use gemini-1.5-pro-latest instead of gemini-pro and your good to go.

you need to be whitelisted.

@haseeb-heaven
Copy link
Author

Im using this library to work with Gemini pro 1.5 the code is the same its just a different model. You use gemini-1.5-pro-latest instead of gemini-pro and your good to go.

you need to be whitelisted.

But how to get whitelisted please explain that in details thanks

@LindaLawton
Copy link

If you are white Listed for ai studio you will get in eventually

If you're not you need to apply to be white Listed

In both cases you just wait

@haseeb-heaven
Copy link
Author

If you are white Listed for ai studio you will get in eventually

If you're not you need to apply to be white Listed

In both cases you just wait

I tried to list all the models available and i got this list.

def list_all_models():
    try:
        models = genai.list_models()
        for model in models:
            print(f"Name: {model.name}, Display Name: {model.display_name}")
    except Exception as exception:
        print("Error listing models:", exception)

Output:

Name: models/chat-bison-001, Display Name: PaLM 2 Chat (Legacy)
Name: models/text-bison-001, Display Name: PaLM 2 (Legacy)
Name: models/embedding-gecko-001, Display Name: Embedding Gecko
Name: models/gemini-1.0-pro, Display Name: Gemini 1.0 Pro
Name: models/gemini-1.0-pro-001, Display Name: Gemini 1.0 Pro 001 (Tuning)
Name: models/gemini-1.0-pro-latest, Display Name: Gemini 1.0 Pro Latest
Name: models/gemini-1.0-pro-vision-latest, Display Name: Gemini 1.0 Pro Vision
Name: models/gemini-pro, Display Name: Gemini 1.0 Pro
Name: models/gemini-pro-vision, Display Name: Gemini 1.0 Pro Vision
Name: models/embedding-001, Display Name: Embedding 001
Name: models/aqa, Display Name: Model that performs Attributed Question Answering.
Name: models/chat-bison-001, Display Name: PaLM 2 Chat (Legacy)
Name: models/text-bison-001, Display Name: PaLM 2 (Legacy)
Name: models/embedding-gecko-001, Display Name: Embedding Gecko
Name: models/gemini-1.0-pro, Display Name: Gemini 1.0 Pro
Name: models/gemini-1.0-pro-001, Display Name: Gemini 1.0 Pro 001 (Tuning)
Name: models/gemini-1.0-pro-latest, Display Name: Gemini 1.0 Pro Latest
Name: models/gemini-1.0-pro-vision-latest, Display Name: Gemini 1.0 Pro Vision
Name: models/gemini-pro, Display Name: Gemini 1.0 Pro
Name: models/gemini-pro-vision, Display Name: Gemini 1.0 Pro Vision
Name: models/embedding-001, Display Name: Embedding 001
Name: models/aqa, Display Name: Model that performs Attributed Question Answering.

My Google generativeai version:

pip show google-generativeai
Name: google-generativeai
Version: 0.4.1

See the gemini-1.5-pro-latest isn't even listed.

@LindaLawton
Copy link

It will be when they give you access I had to have my project whitelist

@danh-conduit
Copy link

I too get the same result (404) and the same (non-1.5) list of models as everyone else except @LindaLawton, using google-generativeai v 0.4.1. I have AI Studio 1.5 access via both a personal account and a Google Workspace account. I generated API keys from both those accounts but neither of them yields gemini-1.5-pro-latest. Google, please show us the love 🙏

@LindaLawton
Copy link

I can not you must wait to be white Listed to the API it's comming they are releasing it slowly

@MarkDaoust
Copy link
Collaborator

It looks like they've removed the whitelist and opened up access to 1.5 in AI Studio. Hopefully that means it will be accessible in the API soon.

@haseeb-heaven
Copy link
Author

It looks like they've removed the whitelist and opened up access to 1.5 in AI Studio. Hopefully that means it will be accessible in the API soon.

Yes i saw Twitter post about this hopefully we will get the API access soon.

@goodanthony
Copy link

Hope this helps

Firstly Google would send you an invite to join. Then fill that form and you have to specify your project id. Make sure you remember the project id!

First email from Google
Hello,
We're thrilled to announce that we've started rolling out access to the Gemini 1.5 Pro API! This lets you bring the power of Gemini 1.5 Pro beyond Google AI Studio.
How to request access:
Submit one Google Cloud Project Number (digits only) using this form.
We'll email you if access is enabled for your project.
Gemini 1.5 Pro:

Fill form

Reply from Google:
Hello,
We're excited to share that you now have access to the Gemini 1.5 Pro API and the File API! Your feedback on this highly-requested preview feature is incredibly valuable. Please share your thoughts and any projects you build!
Instructions:

Go to https://aistudio.google.com and create a new key with the "Project ID" that you filled in the form (I had to create a new key. If you already have a key with that project ID, I assume it would work).

Then run the following command:

curl
-H 'Content-Type: application/json'
-d '{"contents":[{"parts":[{"text":"Write a story about Wikipedia"}]}]}'
-X POST 'https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-pro-latest:generateContent?key=yourkey

The mistake I made was using a key from a different project.

@haseeb-heaven
Copy link
Author

Thanks all for confirming i am yet to receive my API key from Google once i receive i will update this issue.

@Arkm20
Copy link

Arkm20 commented Apr 5, 2024

I already filled out the form, but it's been some days now... I still haven't got the email regarding the Api access confirmation

@jyx-su
Copy link

jyx-su commented Apr 6, 2024

@goodanthony @Arkm20 @haseeb-heaven Would you mind sharing the link to the form? Thanks.

@Arkm20
Copy link

Arkm20 commented Apr 7, 2024

So it looks like the Gemini 1.5 rates isn't the same... Sad...

Rate limit 2 queries per minute, 1000 queries per day

according to Official Gemini Docs

@Arkm20
Copy link

Arkm20 commented Apr 8, 2024

@goodanthony I still haven't recieved that reply...

@haseeb-heaven
Copy link
Author

@github-actions github-actions bot removed the status:triaged Issue/PR triaged to the corresponding sub-team label Apr 9, 2024
@johnomeara1
Copy link

johnomeara1 commented Apr 10, 2024

The API for Google Gen AI 1.5 is now available. https://developers.googleblog.com/2024/04/gemini-15-pro-in-public-preview-with-new-features.html?m=1

Still not working for me... unless I am doing something wrong?

GoogleGenerativeAIError: [404 Not Found] models/gemini-1.5-pro-latest is not found for API version v1, or is not supported for GenerateContent. Call ListModels to see the list of available models and their supported methods.

The code that generated the above error works perfectly fine with the model code gemini-pro, but not with gemini-1.5-pro-latest

¯\_(ツ)_/¯

@goodanthony
Copy link

@johnomeara1, try creating a new key at https://aistudio.google.com/ with the "Project ID" that you are calling the API.

@johnomeara1
Copy link

Thanks for the tip!

Here's what ended up working for me:

const model = genAI.getGenerativeModel({ model: "gemini-1.5-pro-latest" }, {
    apiVersion: 'v1beta',
});

The key is using API version v1beta, as that is the only version that supports the gemini-1.5-pro-latest model at this time. Although the above code is for the javascript client library, it can be modified for various languages of google's client for generative AI (python, etc.)

@zakcali
Copy link

zakcali commented Apr 10, 2024

I wish to code for golang. any chance to modifiy that code:
model := client.GenerativeModel("Gemini 1.5 Pro")
there are no curly bracets in golang version

@LindaLawton
Copy link

@zakcali your in the wrong forum this is for the python client library you should head over to generative-ai-go for help with golang

@ewantindale
Copy link

Thanks for the tip!

Here's what ended up working for me:

const model = genAI.getGenerativeModel({ model: "gemini-1.5-pro-latest" }, {
    apiVersion: 'v1beta',
});

The key is using API version v1beta, as that is the only version that supports the gemini-1.5-pro-latest model at this time. Although the above code is for the javascript client library, it can be modified for various languages of google's client for generative AI (python, etc.)

Thanks, spent ages debugging this before I found your post. Was this communicated anywhere or were we just supposed to figure it out on our own?

@Arkm20
Copy link

Arkm20 commented Apr 10, 2024

It works fine for me just without the {apiversion}

@haseeb-heaven
Copy link
Author

The API for Google Gen AI 1.5 is now available. https://developers.googleblog.com/2024/04/gemini-15-pro-in-public-preview-with-new-features.html?m=1

Still not working for me... unless I am doing something wrong?

GoogleGenerativeAIError: [404 Not Found] models/gemini-1.5-pro-latest is not found for API version v1, or is not supported for GenerateContent. Call ListModels to see the list of available models and their supported methods.

The code that generated the above error works perfectly fine with the model code gemini-pro, but not with gemini-1.5-pro-latest

¯_(ツ)_/¯

Create new API again and select the project which has access of Gemini 1.5 pro, it’s working for me i created new API key.

@Arkm20
Copy link

Arkm20 commented Apr 10, 2024

All projects have access now to Gemini 1.5 pro.... It's now on Public access.

But I do find the rates to be very annoying. Only 2 requests per minute...

@haseeb-heaven
Copy link
Author

All projects have access now to Gemini 1.5 pro.... It's now on Public access.

But I do find the rates to be very annoying. Only 2 requests per minute...

Wait 2 requests per minute is way too less is there any documentation on API of this Gemini 1.5 pro rate limitations? I know Gemini had 60 RPM

@Arkm20
Copy link

Arkm20 commented Apr 10, 2024

Here: https://ai.google.dev/models/gemini#:~:text=2%20queries%20per%20minute%2C%201000%20queries%20per%20day

@xuanxuanzzzii
Copy link

Description of the feature request:

I want to use latest version of Google Gemini-1.5-pro via API or SDK that can be integrated to our projects.

What problem are you trying to solve with this feature?

Solving the whole codebase upload media and more with 1 Million tokens limit to achieve maximum efficiency from this model.

Any other information you'd like to share?

Here is error i got

Error generating response: 404 models/gemini-1.5-pro-latest is not found for API version v1beta, or is not supported for GenerateContent. Call ListModels to see the list of available models and their supported methods.

Here is the code:

import os
import google.generativeai as genai
from dotenv import load_dotenv

def init_api_keys():
    try:
        load_dotenv()
        api_key = os.getenv("GEMINI_API_KEY")
        genai.configure(api_key=api_key)
    except Exception as exception:
        print("Error in initializing API keys:", exception)
        raise

def generate_response(prompt:str):

  # Set up the model
  generation_config = {
    "temperature": 0.1,
    "top_p": 1,
    "top_k": 1,
    "max_output_tokens": 2048,
  }
  
  model = genai.GenerativeModel(model_name="gemini-1.5-pro-latest",generation_config=generation_config)
  
  prompt_parts = [prompt]
  
  try:
    response = model.generate_content(prompt_parts)
    print(response.text)
  except Exception as exception:
    print("Error generating response:", exception)
    
if __name__ == "__main__":
    init_api_keys()
    prompt = input("> ")
    generate_response(prompt)

hello,do you know how to use this api to get answers for video input

@xuanxuanzzzii
Copy link

Description of the feature request:

I want to use latest version of Google Gemini-1.5-pro via API or SDK that can be integrated to our projects.

What problem are you trying to solve with this feature?

Solving the whole codebase upload media and more with 1 Million tokens limit to achieve maximum efficiency from this model.

Any other information you'd like to share?

Here is error i got

Error generating response: 404 models/gemini-1.5-pro-latest is not found for API version v1beta, or is not supported for GenerateContent. Call ListModels to see the list of available models and their supported methods.

Here is the code:

import os
import google.generativeai as genai
from dotenv import load_dotenv

def init_api_keys():
    try:
        load_dotenv()
        api_key = os.getenv("GEMINI_API_KEY")
        genai.configure(api_key=api_key)
    except Exception as exception:
        print("Error in initializing API keys:", exception)
        raise

def generate_response(prompt:str):

  # Set up the model
  generation_config = {
    "temperature": 0.1,
    "top_p": 1,
    "top_k": 1,
    "max_output_tokens": 2048,
  }
  
  model = genai.GenerativeModel(model_name="gemini-1.5-pro-latest",generation_config=generation_config)
  
  prompt_parts = [prompt]
  
  try:
    response = model.generate_content(prompt_parts)
    print(response.text)
  except Exception as exception:
    print("Error generating response:", exception)
    
if __name__ == "__main__":
    init_api_keys()
    prompt = input("> ")
    generate_response(prompt)

hello,do you know how to use this api to get answers for video input

I use the code and here is the error information:
Error generating response: Timeout of 60.0s exceeded, last exception: 503 failed to connect to all addresses; last error: UNKNOWN: ipv4:142.251.42.234:443: Failed to connect to remote host: FD Shutdown

@haseeb-heaven
Copy link
Author

Description of the feature request:

I want to use latest version of Google Gemini-1.5-pro via API or SDK that can be integrated to our projects.

What problem are you trying to solve with this feature?

Solving the whole codebase upload media and more with 1 Million tokens limit to achieve maximum efficiency from this model.

Any other information you'd like to share?

Here is error i got

Error generating response: 404 models/gemini-1.5-pro-latest is not found for API version v1beta, or is not supported for GenerateContent. Call ListModels to see the list of available models and their supported methods.

Here is the code:

import os
import google.generativeai as genai
from dotenv import load_dotenv

def init_api_keys():
    try:
        load_dotenv()
        api_key = os.getenv("GEMINI_API_KEY")
        genai.configure(api_key=api_key)
    except Exception as exception:
        print("Error in initializing API keys:", exception)
        raise

def generate_response(prompt:str):

  # Set up the model
  generation_config = {
    "temperature": 0.1,
    "top_p": 1,
    "top_k": 1,
    "max_output_tokens": 2048,
  }
  
  model = genai.GenerativeModel(model_name="gemini-1.5-pro-latest",generation_config=generation_config)
  
  prompt_parts = [prompt]
  
  try:
    response = model.generate_content(prompt_parts)
    print(response.text)
  except Exception as exception:
    print("Error generating response:", exception)
    
if __name__ == "__main__":
    init_api_keys()
    prompt = input("> ")
    generate_response(prompt)

hello,do you know how to use this api to get answers for video input

I use the code and here is the error information: Error generating response: Timeout of 60.0s exceeded, last exception: 503 failed to connect to all addresses; last error: UNKNOWN: ipv4:142.251.42.234:443: Failed to connect to remote host: FD Shutdown

you need to see the documentation on how to send video objects with your request.

@IlayBokobza
Copy link

I have read in this stack-overflow post that you need to change to api version to beta.
https://stackoverflow.com/questions/78327178/model-not-found-when-using-gemini-1-5-when-i-have-access-to-1-5

And it seems to be supported by this page on the gemini docs.
https://ai.google.dev/gemini-api/docs/api-versions

The problem is that I have no idea how to implement this in code (dart). If any has any idea I would appreciate the help.

@ewantindale
Copy link

I have read in this stack-overflow post that you need to change to api version to beta. https://stackoverflow.com/questions/78327178/model-not-found-when-using-gemini-1-5-when-i-have-access-to-1-5

And it seems to be supported by this page on the gemini docs. https://ai.google.dev/gemini-api/docs/api-versions

The problem is that I have no idea how to implement this in code (dart). If any has any idea I would appreciate the help.

I'm not a dart guy but looks like you need to use requestOptions:
https://github.com/google-gemini/generative-ai-dart/blob/f3be7bbae79534535ef964e5b0fee5874aef9bdc/samples/dart/bin/function_calling.dart#L42

@IlayBokobza
Copy link

I have read in this stack-overflow post that you need to change to api version to beta. https://stackoverflow.com/questions/78327178/model-not-found-when-using-gemini-1-5-when-i-have-access-to-1-5
And it seems to be supported by this page on the gemini docs. https://ai.google.dev/gemini-api/docs/api-versions
The problem is that I have no idea how to implement this in code (dart). If any has any idea I would appreciate the help.

I'm not a dart guy but looks like you need to use requestOptions: https://github.com/google-gemini/generative-ai-dart/blob/f3be7bbae79534535ef964e5b0fee5874aef9bdc/samples/dart/bin/function_calling.dart#L42

Thanks man that seems to have done it

@markmcd
Copy link
Member

markmcd commented Apr 19, 2024

The original question seems to be well & truly answered. I'm going to lock this thread now - for any other Python SDK issues you can file a new issue, for other languages find the relevant SDK in https://github.com/google-gemini and ask there.

For general chat, head on over to discord: https://goo.gle/gemini-discord

@google-gemini google-gemini locked as resolved and limited conversation to collaborators Apr 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
component:python sdk Issue/PR related to Python SDK type:feature request New feature request/enhancement
Projects
None yet
Development

No branches or pull requests