LonelyTavern

Which API key do you need for AI roleplay, and how to get it

Last updated September 16, 2026 · Any bring-your-own-key app · By the developer of LonelyTavern

The short answer

Pick a provider

Every one of these speaks the same OpenAI-style API, which is why one app can use any of them. Prices are the providers' own, read on September 16, 2026, and they change; the links at the bottom go to the live pages.

Get the key

The steps are the same everywhere: sign in, open the API keys page, create a key, copy it once. Most providers show the full key only at creation; if you lose it, make another.

  1. OpenRouter: openrouter.ai, sign in, Keys, Create key. Name it after the app you will use it in. You can set a spending cap on the key itself. Add credits under Credits, or use a :free model first.
  2. DeepSeek: platform.deepseek.com, API keys, Create new API key. Top up under Billing before the first message; there is no free allowance.
  3. Google Gemini: aistudio.google.com, Get API key. The free tier needs no card. Paid tiers start when you attach a billing account.
  4. OpenAI: platform.openai.com, API keys, Create new secret key. Add prepaid credits under Billing first.
  5. xAI: console.x.ai, create an API key, then purchase credits.
  6. Moonshot: platform.moonshot.ai, API keys, then recharge.

Put it in the app

In LonelyTavern: Settings, Providers, New provider. Pick the preset for your provider and it fills in the name, the base URL, and a sensible default model. Paste the key, tap Save provider, then Use. Other bring-your-own-key apps ask for the same three things:

What a message costs

Providers bill per token, roughly three quarters of a word. A roleplay turn sends the whole recent conversation plus your character's card every time, so the input side dominates. A worked example on DeepSeek Flash at peak prices, with an 8,000-token conversation and a 300-token reply:

Two habits keep bills predictable: cap the context size in the app so old messages are trimmed or summarized instead of resent, and set a per-key spending limit where the provider offers one.

Keep the key safe

Where the key goes on a phone

LonelyTavern is a bring-your-own-key character chat app for iPhone and Android. Presets for the six providers above, any other OpenAI-compatible endpoint by URL, the key in the keychain, and the characters and chats on the device. Free, no account, no ads, 18+.

Download on the App Store Get it on Google Play

Related guides: SillyTavern on iPhone · SillyTavern on Termux (Android) · all guides.

Sources

OpenRouter, DeepSeek, Google, OpenAI, xAI, and Moonshot are independent companies. LonelyTavern is not affiliated with or endorsed by any of them and earns nothing from your provider spending. Prices and policies were read on September 16, 2026 and may have changed since.