<h1 align="center">
<a href="https://prompts.chat">
We would love to accept your patches and contributions to the Gemini API Cookbook. We are excited that you are considering donating some of your time, and this guide will help us be respectful of that time.
Sign in to like and favorite skills
We would love to accept your patches and contributions to the Gemini API Cookbook. We are excited that you are considering donating some of your time, and this guide will help us be respectful of that time.
All contributions to this project must be accompanied by a Contributor License Agreement (CLA). You (or your employer) retain the copyright to your contribution; this simply gives us permission to use and redistribute your contributions as part of the project.
If you or your current employer have already signed the Google CLA (even if it was for a different project), you probably don't need to do it again.
Visit https://cla.developers.google.com/ to see your current agreements or to sign a new one.
Before you start writing, take a look at the technical writing style guide. You don’t need to fully digest the whole document, but do read the highlights so you can anticipate the most common feedback.
Also check out the relevant style guide for the language you will be using. These apply strictly to raw code files (e.g. *.py, *.js), though code fragments in documentation (such as markdown files or notebooks) tend to favor readability over strict adherence.
For Python notebooks (*.ipynb files), consider running
pyink over your notebook. It is not required, but it will avoid style-related nits.
See below for more detailed guidelines specific to writing notebooks and guides.
Small fixes, such as typos or bug fixes, can be submitted directly via a pull request.
Before you send a PR, or even write a single line, please file an issue. There we can discuss the request and provide guidance about how to structure any content you write.
Adding a new guide often involves lots of detailed reviews and we want to make sure that your idea is fully formed and has full support before you start writing anything. If you want to port an existing guide across (e.g. if you have a guide for Gemini on your own GitHub), feel free to link to it in the issue.
When you're ready, start by using the notebook template and following the guidance within.
Before submitting your notebook, it's recommended to run linting and formatting tools locally to ensure consistency and adherence to style guidelines.
First, install the necessary packages using pip:
pip install -U tensorflow-docs
Use the nbfmt tool from tensorflow-docs to automatically format your notebook:
python -m tensorflow_docs.tools.nbfmt path/to/notebook
Replace
path/to/notebook with the actual path to your notebook file.
Use the nblint tool to check for style and consistency issues:
python -m tensorflow_docs.tools.nblint \ --styles=google,tensorflow \ --arg=repo:google-gemini/cookbook \ --arg=branch:main \ --exclude_lint=tensorflow::button_download \ --exclude_lint=tensorflow::button_website \ --arg=base_url:https://ai.google.dev/ \ --exclude_lint=tensorflow::button_github \ path/to/notebook
Replace
path/to/notebook with the actual path to your notebook file.
When accepting a new guide, we want to balance a few aspects.
It is not crucial for a submission to be strong along all of these dimensions, but the stronger the better. Old submissions may be replaced in favor of newer submissions that exceed these properties.
If you have authored a new guide from scratch, you are welcome to include a byline at the top of the document with your name and GitHub username.
H1 header (# in Markdown) for the title.H1. It should look like:
where<a target="_blank" href="URL"><img src="[https://colab.research.google.com/assets/colab-badge.svg](https://colab.research.google.com/assets/colab-badge.svg)" height=30/></a>
URL should be https://colab.research.google.com/github/google-gemini/cookbook/blob/main/ followed by the notebook location in the cookbook.%pip instead of !pip) and imports in a dedicated setup section near the beginning.# @title as the first line.pyink will always be accepted.= sign, while function parameters don't:
var = value function( parameter=value )
Notice the line break after the opening parenthesis and before the closing parenthesis.response = client.models.generate_content( model=MODEL_ID, contents="Here's my prompt", config={ "response_mime_type": "application/json", "response_schema": Schema } )
Notice the line break after the opening triple quotes and before the closing triple quotes.long_prompt = """ Cupcake ipsum dolor. Sit amet marshmallow topping cheesecake muffin. Halvah croissant candy canes bonbon candy. Apple pie jelly beans topping carrot cake danish tart cake cheesecake. Muffin danish chocolate soufflé pastry icing bonbon oat cake. Powder cake jujubes oat cake. Lemon drops tootsie roll marshmallow halvah carrot cake. """
# @title.temperature) without explaining them; focus on what you want to showcase.MODEL_ID="gemini-2.5-flash" # @param ["gemini-2.5-flash-lite", "gemini-2.5-flash", "gemini-2.5-pro", "gemini-3-flash-preview", "gemini-3-pro-preview"] {"allow-input":true, isTemplate: true}
or a list of prompts:prompt = "Detect the 2d bounding boxes of the cupcakes (with 'label' as topping description')" # @param {type:"string"}
prompt = "Draw a square around the fox' shadow" # @param ["Find the two origami animals.", "Where are the origamis' shadows?","Draw a square around the fox' shadow"] {"allow-input":true}
client.models.get('models/gemini-2.5-flash').input_token_limit.user_name, total_countMAX_VALUE, DATABASE_NAMEcalculate_total(), process_data()UserManager, PaymentProcessoruser_utils, payment_gatewayprint() for basic output.display(Markdown()) for formatted Markdown text, print(json.dumps(json_string, indent=4)) for readable JSON, or display(Image()) for images.nbfmt and nblint can help enforce consistency.https://colab.research.google.com/github/{USER}/{REPO}/blob/{BRANCH}/{PATH}.ipynb