Notebooks
G
Google Gemini
Basic Classification

Basic Classification

promptinggemini-cookbookgemini-apiexamplesgemini
Copyright 2025 Google LLC.
[ ]

Gemini API: Basic classification

This notebook demonstrates how to use prompting to perform classification tasks using the Gemini API's Python SDK.

LLMs can be used in tasks that require classifying content into predefined categories. This business case shows how it categorizes user messages under the blog topic. It can classify replies in the following categories: spam, abusive comments, and offensive messages.

[ ]

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.

[ ]

Examples

[ ]
[ ]
[ ]

Spam

[ ]

Neutral

Next steps

Be sure to explore other examples of prompting in the repository. Try writing prompts about classifying your own datasets.