Skip to content

Files

Latest commit

d3f71c1 · Oct 2, 2024

History

History
Cannot retrieve ahead/behind information for this branch.

Folders and files

NameName
Last commit message
Last commit date
Aug 22, 2024
Jul 17, 2024
Oct 2, 2024
Oct 2, 2024
Oct 2, 2024
Jul 23, 2024
Oct 4, 2023
Jul 17, 2024
May 16, 2023
May 3, 2023
Aug 22, 2024
May 3, 2023
Sep 6, 2024
Oct 23, 2023
Feb 22, 2024
Sep 24, 2024

Google AI Python SDK for the Gemini API

PyPI version Python support PyPI - Downloads

The Google AI Python SDK is the easiest way for Python developers to build with the Gemini API. The Gemini API gives you access to Gemini models created by Google DeepMind. Gemini models are built from the ground up to be multimodal, so you can reason seamlessly across text, images, and code.

Get started with the Gemini API

  1. Go to Google AI Studio.
  2. Login with your Google account.
  3. Create an API key.
  4. Try a Python SDK quickstart in the Gemini API Cookbook.
  5. For detailed instructions, try the Python SDK tutorial on ai.google.dev.

Usage example

See the Gemini API Cookbook or ai.google.dev for complete code.

  1. Install from PyPI.

pip install -U google-generativeai

  1. Import the SDK and configure your API key.
import google.generativeai as genai
import os

genai.configure(api_key=os.environ["GEMINI_API_KEY"])
  1. Create a model and run a prompt.
model = genai.GenerativeModel('gemini-1.5-flash')
response = model.generate_content("The opposite of hot is")
print(response.text)

Documentation

See the Gemini API Cookbook or ai.google.dev for complete documentation.

Contributing

See Contributing for more information on contributing to the Google AI Python SDK.

License

The contents of this repository are licensed under the Apache License, version 2.0.