Pi School

Lesson 6

Models

Choose and configure AI models in Pi.

The model you choose is probably the single most important factor in how successful your Pi sessions will be. State-of-the-art models from Anthropic, OpenAI, and Google are highly capable — they write better code, reason through complex problems, and make fewer mistakes. But they cost money per request. Free models cost nothing but don’t match the top models on difficult tasks. Using Pi well means finding the right balance between cost and capability for what you’re trying to do.

An AI model is the engine behind that capability. When you type a message, it’s a model that reads it and figures out how to respond — whether that’s writing code, explaining an error, or running a command.

See which model you’re using

Your current model is shown in the footer at the bottom of the terminal, along with your working directory, session name, and context usage.

Change the model

Type /model to open the model picker, or press Ctrl+L. If the model supports extended thinking, Shift+Tab cycles through thinking levels — the editor’s border color changes to show the current level.

Once you’ve picked a shortlist of models you switch between often (via /scoped-models or the enabledModels setting), Ctrl+P and Shift+Ctrl+P cycle through just that list, which is faster than opening the full picker every time.

Connecting a model

As covered in the Installation lesson, /login is how you connect a model provider:

  • ChatGPT Plus or Pro — officially sanctioned by OpenAI for third-party tools like Pi. The safest subscription path.
  • A free OpenRouter API key — sign up, grab a key, and pick a model tagged :free (for example google/gemma-4-31b-it:free). Zero cost, no local compute required.
  • Claude Pro/Max and GitHub Copilot both show up as /login options, but using them through Pi violates Anthropic’s and GitHub’s terms of service, respectively — both have real enforcement history. Stick with ChatGPT Codex or an API key.

Cloudflare

If you already have a Cloudflare account, you can use it as a model provider. One bill, no extra subscriptions.

AI Gateway routes requests to OpenAI, Anthropic, and Workers AI through a single Cloudflare bill. Set CLOUDFLARE_API_KEY via /login, plus CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_GATEWAY_ID as environment variables:

export CLOUDFLARE_API_KEY=...           # or use /login
export CLOUDFLARE_ACCOUNT_ID=...
export CLOUDFLARE_GATEWAY_ID=...        # create at dash.cloudflare.com → AI → AI Gateway
pi --provider cloudflare-ai-gateway --model "claude-sonnet-4-5"

Workers AI runs open-source models directly on Cloudflare’s network. It’s more limited than AI Gateway since it only hosts the models Cloudflare provides, but it’s there if you want it:

export CLOUDFLARE_API_KEY=...           # or use /login
export CLOUDFLARE_ACCOUNT_ID=...
pi --provider cloudflare-workers-ai --model "@cf/moonshotai/kimi-k2.6"

The “Use an AI gateway” exercise covers the full setup once you’ve finished the lessons.

Every model also has a context window — a limit on how much conversation it can hold at once. The next lesson covers what that means in practice and how Pi manages it.