All posts

#ai #api #opensource #productivity

Bring Your Own API Key AI App Builder: Costs and Setup

Raymond Busuttil · Jul 7 · 9 min read

A bring-your-own-API-key (BYOK) AI app builder lets you connect your own account at an AI provider instead of buying AI credits from the builder. You paste in a key once, the builder uses it to write your app, and your provider bills you directly for what you use. This guide explains how the costs work, how to get a key from each major provider, where AI Code Zero keeps it, and the habits that keep your usage low.

If you have ever wondered what "bring your own key" really means for your wallet, the short version is that you pay for the AI, and only the AI, at the provider's own rates.

In short

  • AI Code Zero is free and open source. The AI is the only part that can cost money, and you pay your provider directly with no markup from AI Code Zero.
  • You can connect Anthropic, OpenAI, Gemini, xAI, DeepSeek or OpenRouter. Create a key on the provider's website and paste it into Settings → AI.
  • Providers charge by tokens, small pieces of text. Prompts, your app's code and the AI's replies all count.
  • Start small, pick the right model and reasoning level, use a fresh chat when a conversation drifts, and check your provider's usage page for the real numbers.

What does "bring your own API key" mean?

An API key is a password-like code from an AI provider. It lets software use the AI on your account, and the provider bills that account. When an app builder says "bring your own key", it means the builder does not sit in the middle selling you AI time. It sends your requests to the provider you chose, using the key you supplied.

Many hosted app builders work differently: you subscribe or buy credits from the builder, and the builder pays for the AI behind the scenes. That can be convenient, since there is one bill and nothing to set up. The trade-off is that the credit meter is the builder's, so you cannot see or control what each request costs at the provider level, and you are tied to whichever models the builder offers.

With BYOK, you choose the provider and the model, you see usage on the provider's own dashboard, and you can switch whenever you like, even in the middle of a project. That is the approach behind our open-source AI app builder, and it is why the generated code and the account stay yours.

How do the costs work?

Providers measure text in tokens. One token is about three-quarters of a word. You are charged for the tokens the AI reads (your message, your app's code, AI Code Zero's instructions and the chat so far) and the tokens it writes (the code and any thinking it does first).

A few consequences follow from that:

  • A build is several requests. One build can involve more than one request to the provider, and each request sends your message, your app's code and the conversation so far.
  • A typical build uses tens of thousands of tokens. Bigger apps, multi-page websites and long conversations use more.
  • Larger models cost more. They write better code for complex projects, but they are slower and pricier per token than smaller ones.
  • Thinking costs tokens. Higher reasoning levels help with tricky logic and use more tokens.

AI Code Zero does not publish prices in this article because providers change them often. Check the pricing page of the provider you pick. Many providers offer a free tier or starter credit, and some require a payment method or prepaid credit before a new key works.

A glowing balance scale with a stack of coin-like discs on one side and a luminous cube on the other, symbolizing paying only for what you use
With your own key, you pay your provider for the tokens you use, and nothing on top.

Which AI providers does AI Code Zero support?

You can connect any one of these, and switch later:

  • Anthropic (Claude), marked as recommended in AI Code Zero
  • OpenAI (GPT), using a model that supports tool calling
  • Gemini (Google)
  • xAI (Grok)
  • DeepSeek
  • OpenRouter, one key that reaches models from many companies

If you are not sure which to choose, start with your provider's current general-purpose model. You can change the model at any time. The full list and notes live in the AI providers guide.

How do you get an API key?

The steps are the same everywhere:

  1. Open your provider's key page. Sign in or sign up, then open the API keys page. During setup, a Get a key button in AI Code Zero opens the right page for you.
  2. Create a key. Name it something like "AI Code Zero" and copy it right away. Many providers show a key only once.
  3. Add billing if asked. If the provider needs a payment method or credit, add it on the same site.

The key pages for each provider:

Treat the key like a password. Do not paste it into a public chat or commit it to a repository.

How do you connect the key in AI Code Zero?

You can do this during first-run setup, or any time in Settings:

  1. Click Settings and open the AI tab.
  2. Under AI coding provider, choose your Provider.
  3. Paste your API key.
  4. Choose a Model. The list loads from your provider once your key is in. If it does not, click Refresh models or type the model's exact name.
  5. Click Test connection, then Save.

That is the whole setup. There is no AI Code Zero account to create, in the desktop app or the web app.

Where does AI Code Zero store your key?

It depends on where you run it:

  • Desktop app: the key is encrypted by your computer's keychain and kept only on your computer. After saving, AI Code Zero cannot show the key again. To change it, enter a new one. On Linux without a keychain, the protection is weak, so install GNOME Keyring or KWallet.
  • Browser version (web.aicodezero.com, Pinokio, running from source or Docker): the key is saved in your browser, which sends it straight to your provider. It never reaches the AI Code Zero server. The browser keeps it unencrypted, so anyone who can use your browser profile on that computer could read it.

Either way, your key is never written into your projects or anything you export or publish. We cover the thinking behind keeping data on your own machine in why a local-first AI builder matters.

How do you keep AI app builder costs down?

Costs track tokens, so the habits that save money are the habits that keep requests small and focused.

  • Start small, then add. A short first prompt and a few targeted changes often beat one enormous prompt, and each request carries less. Our guide to writing prompts for an AI app builder shows how.
  • Match the model to the job. Larger models suit complex apps and games. Smaller, quicker models are cheaper and fine for simple pages. You can switch mid-project.
  • Tune reasoning. In Settings → AI, Reasoning runs from Off up to Max, and the default is Medium. Lower is faster and cheaper, higher helps with tricky logic. The list shows only what your provider and model support.
  • Edit by clicking when you can. In the Website studio, direct editing of text, pictures and links needs no AI request at all.
  • Start a new chat when a long one drifts. Every request resends the conversation so far, so a fresh chat (the + key, which keeps your version history) keeps requests lean.
  • Use Ask mode for questions. In Ask mode the AI only answers, without touching your app, and it never uses reasoning.
  • Leave optional extras off. Suggested prompts is off by default because it uses a few extra tokens, and web search adds your provider's per-search charge on top of normal tokens.
  • Cancel early if a build is going the wrong way. But note that you are still billed for the part it already did.

Does prompt caching reduce the bill?

Yes, and you do not have to set anything up. Many requests start with the same text, such as AI Code Zero's instructions, your finished home page when building extra pages, and the earlier steps of an edit. Providers can remember that opening text for a few minutes and charge much less to reuse it.

  • OpenAI, Gemini, xAI and DeepSeek cache on their own. AI Code Zero puts the shared text first so they can spot it.
  • Anthropic, and Claude models through OpenRouter, cache only text marked for reuse. AI Code Zero adds the marks.
  • With Claude, saving text to the cache costs about 25 percent more the first time, and reads from the cache cost a tenth of the normal price or less, so it pays off on the first reuse.

The cache lasts only a few minutes, so steady work saves the most. After a break, the next request reads everything in full again. Multi-page websites and multi-step edits benefit most. The details are in the prompt caching documentation.

How do you see what you are spending?

AI Code Zero shows an estimate of the tokens the current chat has used, for example "Est. 12.4k tokens", in the Build pane's header. Click it for a breakdown into input, cache reads, cache writes and output, plus what your last message used.

Treat it as a guide, not a bill. It adds up the counts your provider reports, providers price cached input, output and web searches differently, and a request you stop partway is partly estimated. Your provider's usage or billing page is the source of truth.

It is also worth setting a safety net at the provider. Most providers let you cap monthly spending or add credit in fixed amounts, which turns a surprise into a hard limit. Check your provider's billing settings for what is available. For a key you create just for AI Code Zero, naming it clearly makes it easy to track and to revoke later.

Frequently asked questions

Is a bring-your-own-key builder cheaper than a subscription?

It depends on how much you build. With BYOK you pay only for the tokens you use, so light use costs little and heavy use costs more. Compare your likely usage with the subscription terms of any builder you are considering, and use a provider's free tier or starter credit to try it first.

Does AI Code Zero add a markup to my AI usage?

No. AI Code Zero is free under the MIT license and adds no markup. You pay your AI provider directly. Neither the desktop app nor the web app requires an AI Code Zero account, subscription or card.

Can I switch providers or models later?

Yes. Choose another provider in Settings → AI, save, and carry on. You can also change the model mid-project. Your projects, versions and exports are not tied to any provider.

Is my key safe if I publish or export my app?

Your provider key is never written into projects, exports or published sites. Some extensions use values that are meant to be public, such as a form key, and those do appear in your pages. The extensions documentation explains what goes where, and our extensions page lists them.

Get started with your own key

Create a key with the provider you prefer, paste it into AI Code Zero and build something small to see what your usage looks like. AI Code Zero is free and open source. Download it for Windows (Microsoft Store) or Linux (.AppImage and .deb), install it on a Mac in one click through Pinokio with the Mac guide, or try the web app in your browser with no account. If you are weighing it against hosted builders, see our comparison of Lovable and Bolt alternatives.