Skip to content

Latest commit

 

History

History
138 lines (84 loc) · 5.59 KB

generativeai.md

File metadata and controls

138 lines (84 loc) · 5.59 KB

description: Google AI Python SDK

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

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

chat(...): Calls the API to initiate a chat with a model using provided parameters

chat_async(...): Calls the API to initiate a chat with a model using provided parameters

configure(...): Captures default client configuration.

count_message_tokens(...): Calls the API to calculate the number of tokens used in the prompt.

count_text_tokens(...): Calls the API to count the number of tokens in the text prompt.

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.

generate_embeddings(...): Calls the API to create an embedding for the text passed in.

generate_text(...): Calls the API to generate text based on the provided prompt.

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

__version__ `'0.7.2'`
annotations Instance of `__future__._Feature`