Skip to Content

One key, three fields, and a green check mark

Your workspace is installed, and typing into it does nothing useful yet: it has no AI provider. This article gets you one — an OpenRouter account and key, then the three settings that turn that key into a working route.
September 12, 2026 by
One key, three fields, and a green check mark
OdooBot
bring your own key
Pi Agent Guide · Part 3

One key, three fields, and a green check mark

Your workspace is installed, and typing into it does nothing useful yet: it has no AI provider. This article gets you one — an OpenRouter account and key, then the three settings that turn that key into a working route.

8 steps
On a phone or a computer
3 fields
Endpoint, key and model ID must all match
About 3 min
Inside Pi Agent, once you have the key
Why you bring the key

Pi Agent supplies the workshop, not the engine

Pi Agent uses BYOK — bring your own key. The add-on does not choose an AI service for you and does not pay for one: you open an account, create a key, and paste it in. Three consequences follow.

In plain terms

Think of a stereo. The amplifier is wired up and the speakers are on the shelf. Nothing plays until you connect a source. This article connects one.

  • You pick the model, and can change it later without reinstalling anything.
  • You pay the provider directly; the add-on charges nothing.
  • The key stays on your hardware, sent only to the provider you configured.

OpenRouter goes first here for three practical reasons: one key reaches model families from several vendors through an OpenAI-compatible gateway; sign-up takes an email address or a supported sign-in provider, with whatever verification its current page asks for; and it is built for API access from many regions, though model and payment availability still vary by country.

It is a gateway, not a model developer: one key reaches a catalog that changes over time, where a direct provider gives you its own catalog only, and data handling follows OpenRouter's terms plus the selected model provider and your privacy settings. No provider is best at every task, and many people keep two or three — that is Part 6. For now, one working key is the whole job.

You are not locked into OpenRouter. It is the first walkthrough, not a requirement. Appendix B of the source guide lists the supported direct vendors, and the workflow is almost identical — only the endpoint, mode and model ID change. Check regional availability, billing and API terms for Anthropic, OpenAI and DeepSeek; for Zhipu AI / GLM, its current verification requirements too.
What the key is

A short string of text that spends money

An OpenRouter key is a secret string that normally begins with sk-or-v1-. Pi Agent sends it with every request; OpenRouter checks it, charges the usage to your account, and routes the request to the model you chose.

In plain terms

It works like the order card on a restaurant table. It identifies the table, not you, and everything written on it lands on one bill. Anyone who picks it up can order.

Since Pi Agent v0.13.0, provider keys are stored locally in /data/pi-agent/models.json on your Home Assistant host, in the add-on's persistent data. WoowTech does not receive the key, but anyone with sufficient access to the host or that data can read the file.

flowchart LR
  A["Your browser"] --> B["pi-web on your HA host"]
  B --> C["/data/pi-agent/models.json
where the key is stored"] B --> D["https://openrouter.ai/api/v1
the endpoint you configure"] D --> E["The upstream model
that writes the answer"]
Where the key travelsThe documented path. BYOK does not decide how OpenRouter or the upstream provider handle what you send.

Treat it like a payment credential. Three places are safe: Pi Agent's Models panel; a password manager such as 1Password, Bitwarden, Apple Passwords or KeePass, with a strong master password and multi-factor authentication; and an encrypted offline backup whose restore you have tested. Keep it out of these:

  • Public repositories. Scanners find exposed keys fast, and deleting the latest commit is not enough if the value stays in the Git history.
  • Chat and community groups. Other participants and the service may keep the message.
  • Shared documents. Link-sharing settings are easy to misconfigure, and they change later.
  • Ordinary email. Do not send an API key as email.
  • Screenshots and recordings. Text too small to read is still readable by OCR.
  • Support posts. Use an obviously fake example and redact the whole secret, not just its tail: sk-or-v1-REDACTED.

Appendix B says credentials are redacted in logs at debug level as ***. Read a log yourself before sharing it anyway.

If a key may have leaked, act now. Open OpenRouter's API Keys page, delete or revoke that key, create a replacement, then use Edit on the provider card to update apiKey and Save. Review your usage and account activity for requests you do not recognize, and if paid credit or account information may be affected, follow the support path shown in your account. Rotation stops future use of the old key; it does not undo requests already made.
After you add or rotate a key, take a fresh Home Assistant backup — and treat it as sensitive data, because the documented backup path carries keys and conversations. Moving to another host means moving that .tar file through a process you trust and restoring it there.
Eight steps at OpenRouter

Creating the key, on a phone or a computer

Dashboard labels change. Where the wording differs from what is below, follow the site.

  1. Step 1

    Open the official site

    Go to https://openrouter.ai/settings/keys. Check the address bar reads openrouter.ai, not a look-alike such as openrouter.example.

  2. Step 2

    Sign in, or create an account

    Use a sign-in method OpenRouter currently offers, email or a supported identity provider, and complete any verification it shows. Do not reuse your Home Assistant password.

  3. Step 3

    Read the privacy and data settings

    Do it before adding credit or sending anything private: requests may be handled by the selected model provider, so pick settings and models that suit what you send.

  4. Step 4

    Open the API Keys page

    From the dashboard, open API Keys in Settings. If the labels have changed, follow the current link from the official settings page.

  5. Step 5

    Select Create Key

    OpenRouter may offer an optional credit limit for the key. Set one only if it suits your own budget.

  6. Step 6

    Give it a name you will recognize later

    Name it after the installation it belongs to: pi-agent-home, pi-agent-office, test-2026-08. Separate keys make rotation and usage review far easier.

  7. Step 7

    Create it, then use the Copy button

    Use Copy rather than selecting text by hand, so you do not lose a character. This is the only time the full value is shown; a masked preview such as sk-or-v1-… cannot recover it.

  8. Step 8

    Put it in your password manager

    Save it properly now. A temporary local note is fine — delete it once the setup below is done.

Do not continue until the whole key is stored somewhere safe. If the page no longer reveals it and you did not save it, revoke or delete that key and create another.
What it costs

Tokens, credit, and what the account asks of you

OpenRouter measures usage in tokens, and counts vary by language and by model, so do not work out a bill from a word count. Pi Agent sends your prompt and the relevant conversation context with each request, and the answer costs tokens too.

In plain terms

It is metered like water, not like a monthly ticket. A long conversation is a long shower: the meter keeps running because everything said so far gets sent again as background.

Rates and availability change. Read them in the OpenRouter catalog and your own dashboard, not from a figure printed in any guide, including this one.

What to look atWhere to check itWorth knowing
Input tokensThat model's current input rateConversation history may be sent again as context
Output tokensThat model's current output rateLong answers consume more output tokens
Free model variantsWhether the model ID currently has oneAvailability and limits change; do not assume production capacity
Account creditYour balance and payment optionsUse only the values in your own account

Watch real usage rather than inventing a monthly estimate. Cost follows prompt and response length, context length, model choice and, in video workflows, the number of generation steps. Use a per-key limit if the dashboard offers one, and review each workflow's own usage rather than assuming a fixed cost.

A free model is useful for a first connectivity test, and that is all you should ask of it: free availability and rate limits are not guarantees, so watch its limits. For regular use, choose on current price, privacy policy and output quality. A model ID appearing repeatedly in a walkthrough tells you nothing about whether a free variant exists.
Never hand identity documents to anyone offering to “help” you register. Requirements vary by method, by country and by OpenRouter's own risk checks, so complete only the verification your own account shows you, on the official site. You do not need a mainland-China identity document here, though you may need to verify an email address or satisfy a payment provider if you buy credit — read the payment methods, fees and account terms before you do. Do not work around regional, identity or payment controls: if the flow is not available where you are, pick a provider you can use legitimately, such as a supported direct provider from Appendix B.
The Models panel

A registry of routes, not a list of models

Three small buttons sit at the bottom-left of the workspace sidebar: Models, Skills, Settings. Models opens the settings dialog on its Models tab — a service directory, where each card is one company or gateway you have an arrangement with, holding one endpoint, one credential and its own model entries.

  • Add Provider creates another card — once now, again in Part 6 for a second route.
  • Test is the control that matters: green means the settings can complete a real request, not just that the form saved.
  • Save writes to /data/pi-agent/models.json, which the documented Home Assistant backup path includes.

Add Provider opens a catalog rather than an empty form, grouped by how a provider connects rather than by brand.

The Add provider catalog inside the Settings dialog on its Models tab, with a Search providers box at the top. Under CUSTOM sits a single card, OpenAI / Anthropic compatible, labeled Custom endpoint format with a plus button. Under SUBSCRIPTIONS are six cards, each marked OAuth: Anthropic Claude Pro/Max, GitHub Copilot, Kimi Code, OpenRouter OAuth, Radius and xAI. The API KEY group begins below with Amazon Bedrock at 121 models, Ant Ling at 3 models and Anthropic at 14 models.
The catalogTop of the list: one custom entry, six subscriptions that sign in by OAuth, then the API-key providers with their model counts.
  • CUSTOM holds one card — “OpenAI / Anthropic compatible”, subtitled Custom endpoint format. That is the card this walkthrough uses, because it is the one that asks you for an endpoint and a key by hand.
  • SUBSCRIPTIONS are all marked OAuth. You sign in to a plan you already pay for instead of pasting a secret — note that OpenRouter appears here too, as OpenRouter OAuth, which is not the route this article takes.
  • API KEY cards carry a model count: Amazon Bedrock 121 models, Anthropic 14 models. The number is how many models that one entry can reach.
The lower half of the provider catalog, each card showing a name and a model count: OpenCode Go 27 models, OpenRouter 366 models, three Qwen Token Plan entries at 18, 18 and 9, Radius 0 models, Together 21, Vercel AI Gateway 237, xAI 3, four Xiaomi entries at 3, 2, 2 and 2, Z.AI 7 and Z.AI Coding CN 10.
Breadth in one entryOpenRouter reaches 366 models and Vercel AI Gateway 237, where most single-vendor entries list a handful.
  • OpenRouter, 366 models, sits in this list by name. One account and one key, and the count is the reason this article picked it.
  • Single-vendor entries are much smaller — xAI 3, Z.AI 7, Together 21. Each of those needs its own account.
  • Radius shows 0 models, so being listed here does not mean there is something to select yet.

Two ways in, then. The OpenRouter card fills the endpoint in for you; this article types it out on the custom card, and the three settings are the same either way.

The three fields

The key alone does not tell Pi Agent anything

A value beginning sk-or-v1- is only a credential: Pi Agent cannot work out the endpoint, the API mode or the model ID from it. This is a one-time setup; you return to Models only to rotate a key, add a provider, or change the models on offer.

In plain terms

It is an address, a name and an order. baseUrl is where to knock. apiKey is who is asking. models[].name is what you are asking for. Get any one of the three wrong and the door does not open.

FieldWhat it meansThe OpenRouter value
baseUrlThe endpoint that receives Pi Agent's requestshttps://openrouter.ai/api/v1
apiKeyThe secret that authenticates the usage to your accountThe complete key from step 7, beginning sk-or-v1-
models[].nameThe exact catalog ID to request through this routeanthropic/claude-sonnet-4

All three must agree. The model ID above is the one verified in the repository for this walkthrough; catalogs change, so confirm it is still listed, and otherwise copy an available model's exact ID.

  1. Step 1

    Open Models, then take the custom entry

    Select Models, then Add Provider, and choose the card under CUSTOM labeled OpenAI / Anthropic compatible. The form has Name, API mode, baseUrl and apiKey, then the Models list.

  2. Step 2

    Type a Name you will read later

    OpenRouter is enough. Pi Agent tells cards apart by Name, not by endpoint, so a second key on the same endpoint needs its own name, such as OpenRouter-office.

  3. Step 3

    Set API mode to openai-completions

    The four options are openai-completions, openai-responses, anthropic-messages and google-generative-ai. This base URL exposes an OpenAI-compatible Chat Completions interface, so choose openai-completions; a mismatched mode returns a 400 or 404 rather than a helpful message. A documented direct Anthropic setup uses anthropic-messages, the Google equivalent google-generative-ai, and a documented OpenAI Responses endpoint openai-responses. Appendix B is the provider reference.

  4. Step 4

    Enter the base URL exactly

    Copy https://openrouter.ai/api/v1 with nothing added. Use HTTPS. Do not append /chat/completions, do not leave a trailing slash, and do not paste a dashboard route such as /settings/keys.

  5. Step 5

    Paste the key into apiKey

    Paste from your password manager. The field masks the value; the eye control reveals it briefly. Check both ends for a stray space and remove it with Backspace or Delete — whitespace is the most common paste failure here. To read the whole value, use a local text field, never a shared document or anything you might screenshot.

  6. Step 6

    Add the model, then Test and Save

    Select Add Model, enter anthropic/claude-sonnet-4 as the name, and take the contextWindow figure from that model's own details page — never from a different model. Then Test: a green check mark means it worked, so Save and close the panel. No restart is needed; the next request uses the new configuration.

Test sends a real request through OpenRouter using the model you entered, and it can consume quota or credit — how much depends on the route and the current rate, so read your dashboard rather than assuming it is free. How long it takes depends on the model, the route, your network and the provider's load, so if it stalls, work from the actual error rather than a stopwatch.
Leave Advanced settings alone for now. Turn on reasoning only if the model and route actually support it. Do not enable deepSeekThinkingCompat unless your model needs that compatibility mode, and do not set thinkingLevelMap without model-specific guidance.
The Pi Agent model dropdown, opened from the model button under the message box, listing eight model names: GPT-5.3 Codex Spark, GPT-5.4, GPT-5.4 mini, GPT-5.5, GPT-5.6 Luna, GPT-5.6 Sol with a tick beside it, GPT-5.6 Terra and GPT-6 Astra.
Where it shows upThe picker on a machine configured with a different route. Yours lists the models you entered, not these.
  • The button under the message box carries the current model name — here GPT-5.6 Sol. Selecting it opens this list.
  • The tick marks the model this conversation will send to. Make sure it is the one you tested.
  • The list shows model names only, with no provider prefix, so give each model an ID you can recognize on sight.

Changing a card later, and deleting one

Every provider card has a three-dot menu (⋮) with two actions, not equally reversible.

ActionWhat it doesWhen you want it
EditReopens the form to change baseUrl or apiKey, update the models list, or change reasoning settingsRotating a key, adding a current model such as anthropic/claude-sonnet-4, fixing its context setting
DeleteRemoves the configuration. Old history stays readable, but a Session cannot carry on through a model that is no longer thereYou have stopped using that provider, or the card needs recreating
Think before you delete a provider. Any Session bound to it may fail the moment you continue the conversation — Part 4 explains that binding. If you are moving off a route, leave the card in place while you work out where those Sessions are going, and do not invent a replacement model name to fill the gap.

A second key on the same provider earns its own card in three situations: telling home and office usage apart, with cards named OpenRouter-home and OpenRouter-office; carrying separate per-key limits where the dashboard offers them, though that is no substitute for restricting Home Assistant administrator access; and reducing disruption while you rotate the other key. Follow your organization's rules for business credentials and billing. Add it with Add Provider, a different Name, the same baseUrl, the other apiKey, and anthropic/claude-sonnet-4 only if it is still in the live catalog.

When Test fails

Read the error before you change anything

A failed Test is specific. Match the code to a row rather than editing fields at random.

What Test showsWhat it likely meansWhat to check
401 Unauthorized OpenRouter rejected the credential Reveal the field briefly and look for missing characters or whitespace. Confirm the key is still active in the dashboard; rotate it if not.
404 Not Found The endpoint path or the model ID was not found Set baseUrl to exactly https://openrouter.ai/api/v1 — no trailing slash, no /chat/completions, and not another vendor's endpoint such as https://api.openai.com/v1, where an OpenRouter key will not authenticate. Then check models[].name against the live catalog: glm-4 fails where the ID ends .6.
400 Bad Request The request format does not match the endpoint Almost always the API mode. anthropic-messages does not fit this configuration; select openai-completions and retry.
402 Payment Required The key works, but the route cannot draw on your credit or quota Check your balance and the model's current availability. A new account does not necessarily include free credit.
Timeout, or an endless spinner The request never completed Check outbound DNS and HTTPS with curl -I https://openrouter.ai. If that fails too, try ping 8.8.8.8, then check service status and retry — a ping proves networking only, never API authentication.

Some failures show up in the interface rather than as a status code.

SymptomWhat to do
Test spins for more than 30 secondsIf networking is healthy, refresh pi-web with F5 or Ctrl+R, reopen Models and retry. Rarely, restart the add-on from Settings → Add-ons → Pi Agent → Restart.
Test went green, but the conversation returns 401The conversation is on a different model entry than the one you tested — Models holds anthropic/claude-sonnet-4 while the selector points at something like “OpenRouter / glm-4”. Choose the tested model and check its models[].name.
Every response is slowLatency varies with the model, the upstream provider, the route and current load. Confirm baseUrl, API mode and model ID, then compare another suitable model. A fixed latency threshold is not a reliable diagnosis.
The selector still says “Not set”Select New session — an existing Session can retain its earlier model state — or refresh pi-web with F5. If the list is still empty, check that /data/pi-agent/models.json was written.
The selector says “Unnamed provider”The Name field was left empty. Open the card's three-dot menu, select Edit, type OpenRouter into Name, and save.

And some go wrong before Pi Agent ever sees the key.

Symptom at OpenRouterWhat to do
The sign-in email never arrivesCheck spam and filtered folders, confirm the address, and wait before requesting another. If that method stays unavailable, use another one OpenRouter offers — only from the official sign-in page.
The copied key is rejectedKeys normally begin sk-or-v1- and must be copied in full. Use the Copy button rather than selecting part of the text, strip accidental leading or trailing spaces, and do not add quotation marks. Test confirms the full credential arrived.
The key is gone, from Pi Agent and from the dashboardIf you closed the page before saving it, and models.json has no recoverable backup and your password manager no copy, the value is gone. Create a new key and revoke the missing one if it is still listed — a masked preview is not the full secret.
A model in the catalog will not workAvailability depends on account settings, provider routing, region, credit and the model's own status. Read the model page and the exact error first. F5 may refresh the dashboard, but will not lift an account or provider restriction.
Your account or payment method is not supportedDo not invent account details and do not bypass provider controls. Use a payment method your account is offered, or move to another supported provider from Appendix B.
If you realize you opened a look-alike site, stop. Do not sign in and do not paste the key. Go back to the real openrouter.ai domain, rotate any key you may have exposed, and change any credential you reused elsewhere. Never follow a sign-in link sent by a stranger, and never enter your key on a third-party “verification” page.
Does Pi Agent send my key to WoowTech?
No. The documented path is your browser, then pi-web on your own Home Assistant host, then the OpenRouter endpoint at openrouter.ai. Pi Agent is MIT-licensed open source, so you can check that yourself in pi-web-start.sh and your network configuration. Two caveats: anyone administering the host can read local data, and BYOK says nothing about how OpenRouter or the upstream model provider handle and retain what you send.
Do I need a new key after moving Home Assistant to another host?
No. The key belongs to your OpenRouter account, not to one host. Add it on the new host, or restore the Home Assistant backup containing /data/pi-agent/models.json. The backup article later in this series covers that procedure.
Can one key be used by more than one Pi Agent?
It may work, but separate keys are far easier to rotate and audit, and shared limits make usage hard to attribute. Name one per installation: pi-agent-home, pi-agent-office. Do not assume there is no account limit on keys — the API Keys page is the authority.
Must I enable reasoning?
No, and not by default. Turn it on only if the selected model and route support structured reasoning: a supported route then shows an expandable reasoning block, an unsupported one may do nothing useful with it. Part 5 covers those blocks. deepSeekThinkingCompat is for routes that need DeepSeek compatibility; thinkingLevelMap needs model-specific guidance.
Which file records my Models changes, and can I edit it by hand?
/data/pi-agent/models.json, and the interface manages that JSON for you. Its providers object holds fields matching the form — baseUrl, api, apiKey and models[]. You can edit it, but the interface is safer: one missing or extra comma empties the Models panel and produces a parse error. If you do, validate the JSON and refresh pi-web. Avoid opening or sharing the file — it contains secrets. Appendix C covers bulk work.
Can one provider card hold several models?
Yes — select Add Model while editing the card. Two cautions. The repository snapshot repeats anthropic/claude-sonnet-4 across several example slots: one verified ID shown six times, not six recommendations, and labels such as “primary-model” are placeholders, not catalog IDs. And do not guess availability from a suffix like -flash or -air, or copy an ID from another vendor's documentation such as docs.bigmodel.cn and expect it to resolve on OpenRouter. Use the exact live ID.
Next

Where to go from here

keep going

The route is live. Now say something to it.

Part 4 covers your first real conversation: what to ask, how to read the reply, and what a session keeps between one message and the next.

Open the full guide

Part 3 of the Pi Agent Onboarding Guide series, published by WoowTech.

Based on the Woow HA Pi Agent Onboarding Guide, produced by WoowTech and released under CC BY 4.0.

The Smart Space Solution · 智慧空間解決方案 · © 2026 WOOW Technology Co., Ltd.

Share this post