Notebooks
G
Google Gemini
Entity Extraction

Entity Extraction

gemini-cookbookgemini-apiexamplesgemini
Copyright 2025 Google LLC.
[1]

Gemini API: Entity extraction

Use Gemini API to speed up some of your tasks, such as searching through text to extract needed information. Entity extraction with a Gemini model is a simple query, and you can ask it to retrieve its answer in the form that you prefer.

This notebook shows how to extract entities into a list.

Setup

[2]

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.

[3]

Select the model

Additionally, select the model you want to use from the available options below:

[4]
MODEL_ID

Examples

Extracting few entities at once

This block of text is about possible ways to travel from the airport to the Colosseum.

Let's extract all street names and proposed forms of transportation from it.

[5]

You will use Gemini Flash model for fast responses.

[6]

You can modify the form of the answer for your extracted entities even more:

[7]

Numbers

Try entity extraction of phone numbers

[8]
[9]

URLs

Try entity extraction of URLs and get response as a clickable link.

[10]
[11]