Skip to main content

Google Generative AI High level API client library and tools.

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

google_generativeai-0.2.2-py3-none-any.whl (133.2 kB view details)

Uploaded Python 3

File details

Details for the file google_generativeai-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for google_generativeai-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0fc3e61fbaeddaca590d30cfa1a4b2945db85d2a782f31eef20982457f4cb31f
MD5 1a6385cecddce9205f53d3432229958b
BLAKE2b-256 931a1892cb4d1e925fa26f2b83bc8a6bca861f5e8fe6d5e9d9e983548b6d3532

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page