Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.
This repository was archived by the owner on Dec 16, 2025. It is now read-only.

Google Gemini 1.5 pro via API access #227

Description

@haseeb-heaven

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)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions