Skip to content

Files

This branch is 22 commits behind google-gemini/deprecated-generative-ai-python:main.

samples

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Oct 29, 2024
Aug 22, 2024
Jul 3, 2024
Jul 1, 2024
Aug 22, 2024
Jul 11, 2024
Sep 9, 2024
Aug 22, 2024
Jul 3, 2024
Sep 27, 2024
Jun 28, 2024
Jun 29, 2024
Jun 28, 2024
Jul 3, 2024
Jul 3, 2024
Jul 23, 2024
Aug 22, 2024

Gemini API Python SDK sample code

This directory contains sample code for key features of the SDK, organised by high level feature.

These samples are embedded in parts of the documentation, most notably in the API reference.

Each file is structured as a runnable test case, ensuring that samples are executable and functional. Each test demonstrates a single concept, and contains region tags that are used to demarcate the test scaffolding from the spotlight code. If you are contributing, code within region tags should follow sample code best practices - being clear, complete and concise.

Contents

File Description
cache.py Context caching
chat.py Multi-turn chat conversations
code_execution.py Executing code
configure_model_parameters.py Setting model parameters
controlled_generation.py Generating content with output constraints (e.g. JSON mode)
count_tokens.py Counting input and output tokens
embed.py Generating embeddings
files.py Managing files with the File API
function_calling.py Using function calling
models.py Listing models and model metadata
safety_settings.py Setting and using safety controls
system_instruction.py Setting system instructions
text_generation.py Generating text
tuned_models.py Creating and managing tuned models