Gemini API cookbook
A collection of guides and examples for the Gemini API. Explore more in the Gemini API Cookbook on GitHub.
Quickstart in Python
[
Audio Quickstart
How to prompt Gemini 1.5 Pro using an audio file.](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/quickstarts/Audio.ipynb) [
Authentication Quickstart
Create an API key and use it with the Python SDK or a command line tool like curl.](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/quickstarts/Authentication.ipynb) [
OAuth Quickstart
A simplified approach to using OAuth for authentication.](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/quickstarts/Authentication_with_OAuth.ipynb) [
Tokens Quickstart
An interactive introduction to tokens and how they are used in the Gemini API.](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/quickstarts/Counting_Tokens.ipynb) [
Embeddings Quickstart
Quick code examples that show how to get started generating embeddings.](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/quickstarts/Embeddings.ipynb) [
File API Quickstart
Use the File API to upload a media file and include it in a GenerateContent call.](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/quickstarts/File_API.ipynb) [
Function Calling
Code examples to help you get started with function calling.](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/quickstarts/Function_calling.ipynb) [
Function Calling Config
A guide for those already familiar with function calling.](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/quickstarts/Function_calling_config.ipynb) [
Prompting Quickstart
How to write and run your first prompts with the Gemini API.](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/quickstarts/Prompting.ipynb) [
Safety Quickstart
How to use them the Gemini API adjustable safety settings.](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/quickstarts/Safety.ipynb) [
Streaming Quickstart
This notebook demonstrates streaming in the Python SDK.](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/quickstarts/Streaming.ipynb) [
System instructions
How to provide a system instruction when generating content.](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/quickstarts/System_instructions.ipynb) [
Tuning Quickstart
How to get started with model tuning.](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/quickstarts/Tuning.ipynb) [
Prompting with Video
Quick example of how to prompt Gemini 1.5 Pro using a video file.](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/quickstarts/Video.ipynb)
Quickstart in Rest
[
Embedding Quickstart
How to get started generating embeddings using curl.](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/quickstarts/rest/Embeddings_REST.ipynb) [
Function calling
Quick code examples that show how to get started with function calling using curl.](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/quickstarts/rest/Function_calling_REST.ipynb) [
JSON Mode Quickstart
A code example that shows you how to get started with JSON mode using curl.](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/quickstarts/rest/JSON_mode_REST.ipynb) [
Prompting Quickstart
Try out the Gemini API using curl commands to call the methods in the REST API.](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/quickstarts/rest/Prompting_REST.ipynb) [
Safety Quickstart
How to use adjustable safety settings with REST.](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/quickstarts/rest/Safety_REST.ipynb) [
Streaming Quickstart
This notebook demonstrates streaming in REST.](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/quickstarts/rest/Streaming_REST.ipynb) [
System instructions
How to get started with system instructions using curl.](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/quickstarts/rest/System_instructions_REST.ipynb)
Code examples
[
Anomaly detection
Use the embeddings from the Gemini API to detect potential outliers in your dataset.](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/examples/Anomaly_detection_with_embeddings.ipynb) [
Classify text
Use embeddings to train a model to classify posts based on the topic.](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/examples/Classify_text_with_embeddings.ipynb) [
Guess the shape
How to use multiple images in the same prompt with the Gemini API.](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/examples/Guess_the_shape.ipynb) [
Marketing campaign
Analyze a product sketch and create a marketing campaign & taglines in JSON format.](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/examples/Market_a_Jet_Backpack.ipynb) [
Search Wikipedia using ReAct
Minimal implementation of ReAct: Synergizing Reasoning and Acting in Language Models](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/examples/Search_Wikipedia_using_ReAct.ipynb) [
Search re-ranking using Gemini embeddings
Use embeddings to re-rank search results.](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/examples/Search_reranking_using_embeddings.ipynb) [
Generation for Story Writing
How to write a story using prompt chaining and iterative generation.](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/examples/Story_Writing_with_Prompt_Chaining.ipynb) [
Document search with embeddings
Use the Gemini API to create embeddings so that you can perform document search.](https://colab.research.google.com/github/google-gemini/cookbook/blob/main/examples/Talk_to_documents_with_embeddings.ipynb)