gemini-gradio
is a Python package that makes it very easy for developers to create machine learning apps that are powered by Google's Gemini API.
Installation
You can install gemini-gradio directly using pip:
pip install gemini-gradio
Basic Usage
You'll need to set up your Gemini API key first:
export GEMINI_API_KEY=<your token>
Then in a Python file, write:
import gradio as gr
import gemini_gradio
gr.load(
name='gemini-1.5-pro-002',
src=gemini_gradio.registry,
).launch()
Run the Python file, and you should see a Gradio Interface connected to the Gemini model!
Customization
Once you can create a Gradio UI from a Gemini endpoint, you can customize it by setting your own input and output components, or any other arguments to gr.Interface. For example, the screenshot below was generated with:
import gradio as gr
import gemini_gradio
gr.load(
name='gemini-1.5-pro-002',
src=gemini_gradio.registry,
title='Gemini-Gradio Integration',
description="Chat with Gemini Pro model.",
examples=["Explain quantum gravity to a 5-year old.", "How many R are there in the word Strawberry?"]
).launch()
Composition
Or use your loaded Interface within larger Gradio Web UIs, e.g.
import gradio as gr
import gemini_gradio
with gr.Blocks() as demo:
with gr.Tab("Gemini Pro"):
gr.load('gemini-1.5-pro-002', src=gemini_gradio.registry)
with gr.Tab("gemini-1.5-flash"):
gr.load('gemini-1.5-flash', src=gemini_gradio.registry)
demo.launch()
Under the Hood
The gemini-gradio Python library has two dependencies: google-generativeai and gradio. It defines a "registry" function gemini_gradio.registry, which takes in a model name and returns a Gradio app.
Supported Models in Gemini
All chat API models supported by Google's Gemini are compatible with this integration. For a comprehensive list of available models and their specifications, please refer to the Google AI Studio documentation.
Note: if you are getting an authentication error, then the Gemini API Client is not able to get the API token from the environment variable. You can set it in your Python session like this:
import os
os.environ["GEMINI_API_KEY"] = ...
Metadata
Release files for gemini-gradio 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| gemini_gradio-0.0.3.tar.gz | 117.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gemini_gradio-0.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 123.6 kB
Release files / gemini_gradio-0.0.3.tar.gz
| Download URL | gemini_gradio-0.0.3.tar.gz |
|---|---|
| Size | 117.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6d53c9995ce87f8f8faff98ae23cf54c1634f8315545ee8798ccb321747d1452
|
|
BLAKE2b-256 checksum How to use checksums |
2ba79759ac5c630b4a61ee44be885e3f1cebbbe091d4359cd6f70cb60375c935
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.9.6
|
Release files / gemini_gradio-0.0.3-py3-none-any.whl
| Download URL | gemini_gradio-0.0.3-py3-none-any.whl |
|---|---|
| Size | 6.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bf8f848bd223f80ad446a5f20fc8b67f7b579702671bb897e94600baa1f01478
|
|
BLAKE2b-256 checksum How to use checksums |
cb47645a9b646ce24bc49c71f4fb17f844238bab1b797070e8da68dcba6c4f1c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.9.6
|
Security for gemini-gradio 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.