Getting started

Setup

Three ways to run the code: here in the browser, in Colab with a free Google AI Studio key, or on your own machine with uv. Plus the limits on live runs.

Option 1 No setup

On this site, no setup

Every code chapter has a Run button. Tool scripts run in your browser on Pyodide, which is CPython compiled to WebAssembly. The first run fetches about 10 MB; later runs are quick. Agent scripts run on our server with a shared key, within the limits shown on the right.

Option 2Free tier

In Colab, with your own free key

  1. Get a free API key at aistudio.google.com/apikey. The free tier is enough for every script in the book.
  2. Open any chapter notebook, for example Chapter 9 in Colab.
  3. In the Colab left sidebar, open Secrets (the key icon) and add GOOGLE_API_KEY. The first cells install the pinned packages and then run the book’s scripts as written.
Option 3Your machine

Locally, with uv

You need Python 3.11 or later. If you don’t have it, uv will fetch one.

# Install uv (skip if you already have it)
curl -LsSf https://astral.sh/uv/install.sh | sh
# Windows: powershell -c "irm https://astral.sh/uv/install.ps1 | iex"

git clone https://github.com/RohanYashraj/agentic-ai-for-actuaries-code.git
cd agentic-ai-for-actuaries-code
uv sync

cp .env.example .env    # then paste your key: GOOGLE_API_KEY=...

cd ch09_agentic_foundations
uv run --env-file ../.env python 01_column_agent.py

Prefer plain pip as printed in the book? Run python -m venv .venv, activate it, then pip install -r requirements.txt. To use Claude or OpenAI instead of Gemini, set MODEL_PROVIDER and the matching key in .env and run uv sync --extra anthropic or --extra openai. Chapter 12’s vector script always uses the Google key for embeddings.

Questions

Questions people ask

Can I run the examples without installing anything?

Yes. Tool scripts run in your browser; edit them and run again. Agent scripts run on our server against Gemini, and you watch the tool calls come back. Colab is the third option, and needs only a Google account and a free key.

Is the companion code free?

Yes. The repository is MIT licensed, and every example runs on the Gemini free tier. The datasets are synthetic. Meridian Re, the reinsurer in the case studies, does not exist.

Which framework does the code use?

Agno for agents and Google Gemini as the default model, gemini-3.8-flash. One line in .env switches provider: MODEL_PROVIDER accepts google, anthropic, or openai, and MODEL_ID picks the model.

Does the code here match the book?

The chapter scripts are the source of truth. The browser demos are generated from them when the site is built, live runs execute them as they are, and Colab clones the repository. Where a printed listing has been corrected, the repository's errata section says so.