# SillyTavern

> Connect SillyTavern to the gateway with a Custom (OpenAI-compatible) chat completion source, and keep long role-play contexts from running up costs.

Source: https://oneaiapikey.com/docs/apps/sillytavern

[SillyTavern](https://sillytavern.app) is a locally run interface for character chat and role-play. It connects to the gateway as a custom OpenAI-compatible chat completion source. Checked against SillyTavern 1.19.0.

You need an API key from [API keys](https://oneaiapikey.com/console/keys) and this base URL:

Base URL `https://api.oneaiapikey.com/v1`

## Connect

1. Open **API Connections** (the plug icon in the top bar).
2. Set **API** to **Chat Completion**, and **Chat Completion Source** to **Custom (OpenAI-compatible)**.
3. Set **Custom Endpoint (Base URL)** to the base URL above, including `/v1`. Do not add `/chat/completions`.
4. Paste your key into **Custom API Key**.
5. Click **Connect**, then pick a model from the list or type its id, for example `claude-haiku-4-5`.
6. Send a message. The request shows up on your [usage page](https://oneaiapikey.com/console/usage).

## Keep costs down

Every message re-sends the character card, the world info and the chat history, so long chats get more expensive with each reply.

- Set the **context size** to what the story actually needs rather than the model’s maximum.
- Set **max response length** to a sensible number of tokens.
- Use a fast, low-cost model for everyday chat and switch to a larger one for important scenes.
- Give SillyTavern its own key with a spend limit (see [Cost control](https://oneaiapikey.com/docs/cost-control#limit-what-a-key-can-spend)).

## Troubleshooting

- **Connect fails or returns 404**: the URL must end in `/v1` with nothing after it.
- **401**: the key was pasted with extra spaces, or it was revoked.
- **The reply stops mid-sentence**: the max response length was reached. Raise it, or ask for shorter replies.

> **Source:** Steps follow SillyTavern’s guide to [OpenAI-compatible API connections](https://docs.sillytavern.app/usage/api-connections/openai/). Labels can change between releases.
