Basic Reasoning
Copyright 2025 Google LLC.
Gemini API: Basic reasoning
This notebook demonstrates how to use prompting to perform reasoning tasks using the Gemini API's Python SDK. In this example, you will work through a mathematical word problem using prompting.
The Gemini API can handle many tasks that involve indirect reasoning, such as solving mathematical or logical proofs.
In this example, you will see how the LLM explains given problems step by step.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 144.7/144.7 kB 4.1 MB/s eta 0:00:00
Configure your API key
To run the following cell, your API key must be stored it in a Colab Secret named GOOGLE_API_KEY. If you don't already have an API key, or you're not sure how to create a Colab Secret, see Authentication for an example.
Additionally, select the model you want to use from the available options below:
Examples
Begin by defining some system instructions that will be include when you define and choose the model.
Next, you can define a logical problem such as the one below.
Next steps
Be sure to explore other examples of prompting in the repository. Try creating your own prompts that include instructions on how to solve basic reasoning problems, or use the prompt given in this notebook as a template.