|View source on GitHub
google.ai.generativelanguage, is a low-level auto-generated client library for the PaLM API.
pip install google.ai.generativelanguage
It is built using the same tooling as Google Cloud client libraries, and will be quite familiar if you've used those before.
While we encourage Python users to access the PaLM API using the
google.generativeai package (aka
this lower level package is also available.
Each method in the PaLM API is connected to one of the client classes. Pass your API-key to the class'
when initializing a client:
from google.ai import generativelanguage as glm
client = glm.DiscussServiceClient(
request = glm.GenerateMessageRequest(
content: "Hello! How can I help you today?"
- The API methods also accept key-word arguments.
- Anywhere you might pass a proto-object, the library will also accept simple python structures.
So the following is equivalent to the previous example:
content: "Hello! How can I help you today?"
class AttributionSourceId: Identifier for the source contributing to this attribution.
class BatchCreateChunksRequest: Request to batch create
class BatchCreateChunksResponse: Response from
BatchCreateChunks containing a list of created
class BatchDeleteChunksRequest: Request to batch delete
class BatchEmbedContentsRequest: Batch request to get embeddings from the model for a list of prompts.
class BatchEmbedContentsResponse: The response to a
class BatchEmbedTextRequest: Batch request to get a text embedding from the model.
class BatchEmbedTextResponse: The response to a EmbedTextRequest.
class BatchUpdateChunksRequest: Request to batch update
class BatchUpdateChunksResponse: Response from
BatchUpdateChunks containing a list of updated
class Blob: Raw media bytes.
class Candidate: A response candidate generated from the model.
class Chunk: A
Chunk is a subpart of a
Document that is treated as an independent unit for the purposes of vector representation and storage.
class ChunkData: Extracted data that represents the
class CitationMetadata: A collection of source attributions for a piece of content.
class CitationSource: A citation to a source for a portion of a specific response.
class Condition: Filter condition applicable to a single key.
class Content: The base structured datatype containing multi-part content of a message.
class ContentEmbedding: A list of floats representing an embedding.
class ContentFilter: Content filtering metadata associated with processing a single request.
class Corpus: A
Corpus is a collection of
class CountMessageTokensRequest: Counts the number of tokens in the
prompt sent to a model.
class CountMessageTokensResponse: A response from
class CountTextTokensRequest: Counts the number of tokens in the
prompt sent to a model.
class CountTextTokensResponse: A response from
class CountTokensRequest: Counts the number of tokens in the
prompt sent to a model.
class CountTokensResponse: A response from
class CreateChunkRequest: Request to create a
class CreateCorpusRequest: Request to create a
class CreateDocumentRequest: Request to create a
class CreatePermissionRequest: Request to create a
class CreateTunedModelMetadata: Metadata about the state and progress of creating a tuned model returned from the long-running operation
class CreateTunedModelRequest: Request to create a TunedModel.
class CustomMetadata: User provided metadata stored as key-value pairs.
class Dataset: Dataset for training or validation.
class DeleteChunkRequest: Request to delete a
class DeleteCorpusRequest: Request to delete a
class DeleteDocumentRequest: Request to delete a
class DeletePermissionRequest: Request to delete the
class DeleteTunedModelRequest: Request to delete a TunedModel.
class DiscussServiceAsyncClient: An API for using Generative Language Models (GLMs) in dialog applications.
class DiscussServiceClient: An API for using Generative Language Models (GLMs) in dialog applications.
class Document: A
Document is a collection of
class EmbedContentRequest: Request containing the
Content for the model to embed.
class EmbedContentResponse: The response to an
class EmbedTextRequest: Request to get a text embedding from the model.
class EmbedTextResponse: The response to a EmbedTextRequest.
class Embedding: A list of floats representing the embedding.
class Example: An input/output example used to instruct the Model.
class FunctionDeclaration: Structured representation of a function declaration as defined by the
OpenAPI 3.03 specification <<a href="https://spec.openapis.org/oas/v3.0.3">https://spec.openapis.org/oas/v3.0.3</a>>__.
class FunctionResponse: The result output from a
FunctionCall that contains a string representing the
FunctionDeclaration.name and a structured JSON object containing any output from the function is used as context to the model.
class GenerateAnswerRequest: Request to generate a grounded answer from the model.
class GenerateAnswerResponse: Response from the model for a grounded answer.
class GenerateContentRequest: Request to generate a completion from the model.
class GenerateContentResponse: Response from the model supporting multiple candidates.
class GenerateMessageRequest: Request to generate a message response from the model.
class GenerateMessageResponse: The response from the model.
class GenerateTextRequest: Request to generate a text completion response from the model.
class GenerateTextResponse: The response from the model, including candidate completions.
class GenerationConfig: Configuration options for model generation and outputs.
class GenerativeServiceAsyncClient: API for using Large Models that generate multimodal content and have additional capabilities beyond text generation.
class GenerativeServiceClient: API for using Large Models that generate multimodal content and have additional capabilities beyond text generation.
class GetChunkRequest: Request for getting information about a specific
class GetCorpusRequest: Request for getting information about a specific
class GetDocumentRequest: Request for getting information about a specific
class GetModelRequest: Request for getting information about a specific Model.
class GetPermissionRequest: Request for getting information about a specific
class GetTunedModelRequest: Request for getting information about a specific Model.
class GroundingAttribution: Attribution for a source that contributed to an answer.
class GroundingPassage: Passage included inline with a grounding configuration.
class GroundingPassages: A repeated list of passages.
class HarmCategory: The category of a rating.
class Hyperparameters: Hyperparameters controlling the tuning process.
class ListChunksRequest: Request for listing
class ListChunksResponse: Response from
ListChunks containing a paginated list of
class ListCorporaRequest: Request for listing
class ListCorporaResponse: Response from
ListCorpora containing a paginated list of
class ListDocumentsRequest: Request for listing
class ListDocumentsResponse: Response from
ListDocuments containing a paginated list of
class ListModelsRequest: Request for listing all Models.
class ListModelsResponse: Response from
ListModel containing a paginated list of Models.
class ListPermissionsRequest: Request for listing permissions.
class ListPermissionsResponse: Response from
ListPermissions containing a paginated list of permissions.
class ListTunedModelsRequest: Request for listing TunedModels.
class ListTunedModelsResponse: Response from
ListTunedModels containing a paginated list of Models.
class Message: The base unit of structured text.
class MessagePrompt: All of the structured input text passed to the model as a prompt.
class MetadataFilter: User provided filter to limit retrieval based on
Document level metadata values.
class Model: Information about a Generative Language Model.
class ModelServiceAsyncClient: Provides methods for getting metadata information about Generative Models.
class ModelServiceClient: Provides methods for getting metadata information about Generative Models.
class Part: A datatype containing media that is part of a multi-part
class Permission: Permission resource grants user, group or the rest of the world access to the PaLM API resource (e.g.
class PermissionServiceAsyncClient: Provides methods for managing permissions to PaLM API resources.
class PermissionServiceClient: Provides methods for managing permissions to PaLM API resources.
class QueryCorpusRequest: Request for querying a
class QueryCorpusResponse: Response from
QueryCorpus containing a list of relevant chunks.
class QueryDocumentRequest: Request for querying a
class QueryDocumentResponse: Response from
QueryDocument containing a list of relevant chunks.
class RelevantChunk: The information for a chunk relevant to a query.
class RetrieverServiceAsyncClient: An API for semantic search over a corpus of user uploaded content.
class RetrieverServiceClient: An API for semantic search over a corpus of user uploaded content.
class SafetyFeedback: Safety feedback for an entire request.
class SafetyRating: Safety rating for a piece of content.
class SafetySetting: Safety setting, affecting the safety-blocking behavior.
class Schema: The
Schema object allows the definition of input and output data types.
class SemanticRetrieverConfig: Configuration for retrieving grounding content from a
Document created using the Semantic Retriever API.
class StringList: User provided string values assigned to a single metadata key.
class TaskType: Type of task for which the embedding will be used.
class TextCompletion: Output text returned from a model.
class TextPrompt: Text given to the model as a prompt.
class TextServiceAsyncClient: API for using Generative Language Models (GLMs) trained to generate text.
class TextServiceClient: API for using Generative Language Models (GLMs) trained to generate text.
class Tool: Tool details that the model may use to generate response.
class TransferOwnershipRequest: Request to transfer the ownership of the tuned model.
class TransferOwnershipResponse: Response from
class TunedModel: A fine-tuned model created using ModelService.CreateTunedModel.
class TunedModelSource: Tuned model as a source for training a new model.
class TuningExample: A single example for tuning.
class TuningExamples: A set of tuning examples.
class TuningSnapshot: Record for a single tuning step.
class TuningTask: Tuning tasks that create tuned models.
class UpdateChunkRequest: Request to update a
class UpdateCorpusRequest: Request to update a
class UpdateDocumentRequest: Request to update a
class UpdatePermissionRequest: Request to update the
class UpdateTunedModelRequest: Request to update a TunedModel.