Module: google.generativeai#
View source on GitHub |
Google AI Python SDK
Setup#
pip install google-generativeai
GenerativeModel#
Use genai.GenerativeModel
to access the API:
import google.generativeai as genai
import os
genai.configure(api_key=os.environ['API_KEY'])
model = genai.GenerativeModel(model_name='gemini-1.5-flash')
response = model.generate_content('Teach me about how an LLM works')
print(response.text)
See the python quickstart for more details.
Modules#
caching
module
protos
module: This module provides low level access to the ProtoBuffer “Message” classes used by the API.
types
module: A collection of type definitions used throughout the library.
Classes#
class ChatSession
: Contains an ongoing conversation with the model.
class GenerationConfig
: A simple dataclass used to configure the generation parameters of GenerativeModel.generate_content
.
class GenerativeModel
: The genai.GenerativeModel
class wraps default parameters for calls to GenerativeModel.generate_content
, GenerativeModel.count_tokens
, and GenerativeModel.start_chat
.
Functions#
configure(...)
: Captures default client configuration.
create_tuned_model(...)
: Calls the API to initiate a tuning process that optimizes a model for specific data, returning an operation object to track and manage the tuning progress.
delete_file(...)
: Calls the API to permanently delete a specified file using a supported file service.
delete_tuned_model(...)
: Calls the API to delete a specified tuned model
embed_content(...)
: Calls the API to create embeddings for content passed in.
embed_content_async(...)
: Calls the API to create async embeddings for content passed in.
get_base_model(...)
: Calls the API to fetch a base model by name.
get_file(...)
: Calls the API to retrieve a specified file using a supported file service.
get_model(...)
: Calls the API to fetch a model by name.
get_operation(...)
: Calls the API to get a specific operation
get_tuned_model(...)
: Calls the API to fetch a tuned model by name.
list_files(...)
: Calls the API to list files using a supported file service.
list_models(...)
: Calls the API to list all available models.
list_operations(...)
: Calls the API to list all operations
list_tuned_models(...)
: Calls the API to list all tuned models.
update_tuned_model(...)
: Calls the API to push updates to a specified tuned model where only certain attributes are updatable.
upload_file(...)
: Calls the API to upload a file using a supported file service.
Other Members | |
---|---|
|
|
Instance of |