Toupas

Blog · 17 November 2026

Let your app's users bring their own Claude, OpenAI or Gemini key

You've added AI to your app. If everyone uses your key, you pay for everyone's usage, and one heavy user can run up your bill. The common answer is bring your own key (BYOK): each person adds their own key for Claude, OpenAI or Gemini, and pays for what they use.

It sounds simple. The hard part is keeping those keys safe, including from you. Here's what a good setup does, and how to build one from a chat.

Each person's key is used only for their own requests. The owner sees only that a key is set and its last few characters, never the key.

What a safe setup looks like

A user's API key is as good as their credit card for that service. So:

  1. The page can save a key, but never read it back. After saving, people see "Saved · ends in x7Q2", with Replace and Remove. A key that can be read back can be stolen by anything running in the page.
  2. It's kept encrypted, with the encryption key held somewhere else. A copy of the database alone doesn't reveal anyone's key.
  3. Only that person's key is used for their requests, never someone else's, even by mistake.
  4. The app's code never handles the key. The request is sent with the key added on the way out. Code that never sees a key can't log it, show it or send it somewhere else.
  5. The owner can't read it. Not on the admin page, not in exports. You see that a key is set, and its last few characters.

Point 5 surprises people building their first BYOK app. But if you can read your users' keys, so can anyone who gets into your account, and your users have to trust you never will.

Why not just save it in the browser?

Keeping the key in the browser's storage and calling the AI service straight from the page is the quickest way to build this. It means the key sits in the page, where any script, browser extension or bug can read it. Some AI services also block calls made straight from browsers. More on keys in the frontend here.

Build it from a chat

With Toupas added to your chat, and an app that already has an AI assistant:

Let each person who uses my app add their own AI keys for Claude,
OpenAI and Gemini, and pick which one to use in each chat.
Add an "AI keys" panel with step-by-step help on getting a key from each
service, and a reminder to set a spending limit.

Toupas has a field type for exactly this, a secret. It does each of the five things above:

When you approve the app's changes in the Toupas panel, it says plainly that keys people save for themselves never reach you.

What to tell your users

Put this in the keys panel, in your own words:

Things to know

Questions

What does BYOK mean for AI apps?

Bring your own key: each user adds their own API key for an AI service and pays for their own usage, instead of the app owner paying for everyone.

Is it safe to let users enter their OpenAI API key in my app?

It can be, if the key is stored encrypted on the server, can't be read back by the page or the owner, and is only used for that person's own requests.

Should I store user API keys in the browser?

No. Anything in the browser can be read by scripts in the page and by extensions. Keep them on the server, encrypted.

Can my app's users sign in with their Claude or OpenAI account instead of a key?

Not for API access today. These services issue API keys from their developer consoles, so users paste a key.

Add Toupas to your chat

Keep reading