Skip to main content

Google Generative AI Python Client

PyPI version Python support PyPI - Downloads

Get started using the PaLM API in Python. Check out the developer site for comprehensive documentation.

Installation and usage

Install from PyPI.

pip install google-generativeai

Get an API key from MakerSuite, then configure it here.

import google.generativeai as palm

palm.configure(api_key=os.environ["PALM_API_KEY"])

Use palm.generate_text to have the model complete some initial text.

response = palm.generate_text(prompt="The opposite of hot is")
print(response.result)  # cold.

Use palm.chat to have a discussion with a model.

response = palm.chat(messages=["Hello."])
print(response.last) #  'Hello! What can I help you with?'
response.reply("Can you tell me a joke?")

Documentation

Checkout the full API docs, the guide and quick starts.

Colab magics

Once installed, use the Python client via the %%palm Colab magic. Read the full guide here.

%%palm
The best thing since sliced bread is

Metadata

Release files for google-generativeai 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for google-generativeai 0.2.0
File Interpreter ABI Platform Actions
google_generativeai-0.2.0-py3-none-any.whl Python 3 none any Details for google_generativeai-0.2.0-py3-none-any.whl

Release files / google_generativeai-0.2.0-py3-none-any.whl

Download URL google_generativeai-0.2.0-py3-none-any.whl
Size 130.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
08ce9aab16f81e4220464829a9cdf0a1e76ab9e4244451d06bf0446269f97309
BLAKE2b-256 checksum
How to use checksums
9df1a72d639a73d688dec704846961ed3fe04ca9d71d22ba236a9366d1a2de12
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Security for google-generativeai 0.2.0

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.

Release history Release notifications | RSS feed

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page