EN ▾
Get API key

GLM API in SillyTavern: Setup for Roleplay Chats

SillyTavern can connect to any OpenAI-compatible endpoint through its custom chat completion source, so a GLM-style API setup takes one screen. Below are the exact fields, sensible settings for long roleplay sessions and the costs to expect.

Updated

Stage with speech bubbles and a mask linked by a cable to a server, illustrating roleplay with an API

Key points

  • In SillyTavern choose Chat Completion, then the Custom (OpenAI-compatible) source, and enter https://api.glmapikey.com/v1.
  • Type uncensored as the model ID. It is the only model this API serves.
  • Context size drives the bill, because every turn resends the chat. Around 32k is a cheap, comfortable default.
  • Group chats can hit the concurrency limit. A trial key allows 2 requests at once, a full key 8.

Connect in five steps

This is the fast path for glm api sillytavern setups. It assumes you already run SillyTavern and have created a key on the API key page.

  1. Open the plug icon (API Connections) at the top of SillyTavern.
  2. Set the API type to Chat Completion.
  3. Set the Chat Completion Source to Custom (OpenAI-compatible).
  4. Paste https://api.glmapikey.com/v1 into the custom endpoint field and your key into the custom API key field.
  5. Enter uncensored as the model ID and press Connect.

A green status light and a model name below the button mean the connection works. Send a message to a character and a reply should stream in. Menu names shift a little between SillyTavern releases, so if a label differs, look for the field that takes an endpoint URL; the values stay the same.

One honest note on the name. This endpoint is not the official GLM API from any vendor, and it does not route to other vendors' models. It is a single open-weight model run by an independent provider, tuned to answer without content refusals for lawful adult use. What it shares with the model families people look for under the GLM name is the interface: a standard OpenAI-style chat completions API that roleplay front ends already know how to talk to.

What you are connecting to

The facts that matter for roleplay, in one place:

PropertyValue
EndpointPOST /v1/chat/completions
Model IDuncensored
Context window100,000 tokens, prompt plus reply
StreamingYes, server-sent events
Passed-through samplerstemperature, top_p, stop, seed, presence and frequency penalties
Price$0.15 per 1M input, $0.50 per 1M output
Limits, full key8 concurrent, 300 per minute
Limits, trial key2 concurrent, 60 per minute

The model is meant for fiction, roleplay and companion apps used by adults. It will stay in character and will not break a scene to lecture you about it. One rule has no exceptions: the service refuses any sexual content involving minors, and character cards that try to set up such a scenario will not work. Keep your cards and prompts on the right side of that line.

Prompts are not used for training, so your characters and chat logs are not fed back into a model. They do pass through the provider to generate a reply, as with any hosted API.

Settings worth changing after you connect

Open the AI Response Configuration panel (the sliders icon). You do not need to touch much, but a few values decide how the chat feels and what it costs.

Context size

This is how many tokens SillyTavern sends with each request: character card, lore, system prompt and as much recent chat as fits. The API allows up to 100,000 tokens, but you do not have to use all of it. A setting of 16,000 to 32,000 keeps replies on topic and keeps the bill small. Raise it when a long story needs the model to recall details from far back. The calculation further down shows why this matters.

Max response length

Set a ceiling that suits your style. 300 to 500 tokens suits short exchanges, and 800 or more suits scene-writing. A lower value also shortens the wait before each reply ends.

Streaming

Leave it on. Replies appear word by word, and you can stop one that has gone the wrong way and not pay for the rest of it. Keep in mind that a streaming request holds a concurrency slot until the stream ends.

Temperature and penalties

Start with temperature around 0.8 and top_p around 0.9. If replies repeat phrases, add a small frequency penalty such as 0.3. If the model wanders off the card, lower the temperature to 0.6. These are starting points to adjust by feel, not magic numbers, and the seed parameter is passed through if you want repeatable output while you tune.

Instruct and prompt format

With the Chat Completion source, SillyTavern builds the message list itself, so you do not need to pick an instruct template. Use the prompt manager to order the system prompt, character description, scenario and chat history, and keep your own style instructions short and direct.

What a roleplay session costs

Roleplay is input-heavy. Each turn resends the card, the lore and the recent chat, and the model answers with a few hundred tokens. Take a context of 30,000 tokens and a 300-token reply:

  • Input: 30,000 / 1,000,000 x $0.15 = $0.0045
  • Output: 300 / 1,000,000 x $0.50 = $0.00015
  • Total: $0.00465 per turn, so 100 turns cost $0.465

Now compare a context of 8,000 tokens with the same reply: input is $0.0012, output is $0.00015, so $0.00135 per turn and $0.135 for 100 turns. The smaller context is about a third of the price. The trade is that the model sees less history, so it may forget a detail from an hour ago. Lorebook entries and a short running summary let you keep the facts you care about in a small context.

Even the larger figure is modest. A trial credit of $0.50 covers roughly 107 turns at 30,000 tokens of context ($0.50 / $0.00465), which is enough to judge whether the model suits your characters. After that you top up with any whole amount from $20 to $500, and credit never expires. Bonuses apply from $50 (+5%), $100 (+10%) and $200 (+15%). Full numbers are on the pricing page.

Group chats and the concurrency limit

SillyTavern group chats send one request for each character that speaks. Features such as swipes, regenerate and background summaries can also start requests in quick succession. If several of them overlap, you may see a 429 error with the code concurrency. It means too many requests were running at once, not that anything is wrong with your key.

A trial key allows 2 concurrent requests and 60 per minute. A funded key allows 8 and 300. To stay inside the lower limit:

  • Wait for a reply to finish before you regenerate.
  • In groups, keep character reply order manual or sequential instead of letting several characters answer together.
  • Turn off extensions that fire requests on every message, such as auto-summaries, until you have a funded key.

The API also returns 429 with a Retry-After: 5 header when it is briefly overloaded. In that case, wait five seconds and press generate again. Failed and refused requests are not charged, so there is no cost to trying again.

Troubleshooting

If the Connect button fails, test the key outside SillyTavern so you know which side has the problem:

curl https://api.glmapikey.com/v1/models \
  -H "Authorization: Bearer $API_KEY"

A JSON list that includes uncensored means the key and URL are right, and the fault is in the SillyTavern fields.

  • Status stays red or you see a 404. The endpoint probably has a trailing path or is missing /v1. Use exactly https://api.glmapikey.com/v1.
  • 401 error. The key was pasted with a space or line break. Paste it again.
  • Replies cut off mid-sentence. Your max response length is too low. Raise it.
  • Replies ignore the character. The card is probably being trimmed because the context size is too small for it. Raise the context or shorten the card.
  • The key stops working after a while. The trial credit lasts 7 days, so top up to continue.
  • SillyTavern on a phone or another device cannot connect. Check that the device has internet access and that the URL was typed exactly, then run the curl test from that device.

For more on request fields and headers, see the documentation. If you want to understand how to get a key in the first place, the GLM key explainer walks through it.

Questions and answers

Which source do I pick in SillyTavern?

Choose Chat Completion as the API type and Custom (OpenAI-compatible) as the source. Then enter the base URL, your key and the model ID uncensored.

Is this the official GLM API?

No. It is a single open-weight model run by an independent provider behind an OpenAI-compatible interface. It is not the official API of any model vendor.

How much does a roleplay session cost?

With a 30,000-token context and 300-token replies, one turn costs about $0.00465, so 100 turns cost around $0.47. A smaller context cuts that figure.

Can I use it for adult roleplay?

The model is tuned to answer without content refusals for lawful adult use, in fiction and companion apps. Sexual content involving minors is never allowed.

Why do I get 429 errors in group chats?

Group chats send several requests at once, and the trial key allows only 2 concurrent requests. Wait for replies to finish or move to a full key with 8.

Your key is one form away

Create an account, copy the key, change the base URL. That is the whole setup.

Get API key