Safa API · aisafa.xyz

SillyTavern API Setup Guide (2026): Connect Claude, GPT & Gemini the Easy Way

发布于 2026-07-05 · Safa API

To connect SillyTavern to Claude, GPT, or Gemini, open API Connections, choose Chat Completion, select the Custom (OpenAI-compatible) source, then paste your provider's base URL and API key. Any relay that exposes a standard /v1/chat/completions endpoint works, so you can point every model at one URL instead of juggling three separate accounts. This guide walks through the exact fields, a working proxy config, and how to do it without a foreign credit card.

What you need before you start

SillyTavern is a front end — it does not host any model itself. It sends your chat history to whatever API you configure and renders the reply. So the only real prerequisites are:

The most common headache for new users is the second point. Anthropic and OpenAI each use their own base URL and their own auth scheme, and both require a payment method that many users outside the US or EU cannot easily add. That is why most SillyTavern users route through an OpenAI-compatible relay that normalizes all three model families behind one URL and one key.

Step-by-step: Chat Completion setup

Open SillyTavern and click the plug icon (API Connections) in the top bar. Then:

  1. Set API to Chat Completion.
  2. Set Chat Completion Source to Custom (OpenAI-compatible).
  3. In Custom Endpoint (Base URL), paste your relay URL, e.g. https://api.example.com/v1.
  4. In Custom API Key, paste your key (usually starts with sk-).
  5. Click Connect. If the key is valid, the model dropdown fills automatically.
  6. Pick a model, for example claude-sonnet-4-6, gpt-5.5, or gemini-2.5-pro.

Note the base URL should usually end in /v1 (SillyTavern appends /chat/completions itself). If you get a 404, that is almost always a trailing-slash or missing-/v1 issue.

Native Claude vs. OpenAI-compatible

SillyTavern also has a dedicated Claude source that uses Anthropic's native Messages format. It works, but it locks you into one vendor and one key. The OpenAI-compatible path is more flexible: you can switch between Claude, GPT, and Gemini from the same connection just by changing the model name in the dropdown. For most people running character cards and swapping models to compare tone, the compatible route is the smoother choice.

ApproachModelsKeys to manageBest for
Native Claude sourceClaude only1 (Anthropic)Claude-only users
Native OpenAI sourceGPT only1 (OpenAI)GPT-only users
Custom (OpenAI-compatible)Claude + GPT + Gemini1 (relay)Model switching

Recommended generation settings

For roleplay and long-form chat, a few settings make a big difference:

If you use large system prompts or long character definitions, look for a provider that supports prompt caching. The static part of your prompt (the persona, world info, and instructions) gets cached on the server, so you only pay full price for it once instead of on every single message. Over a long session, that can cut token spend dramatically.

Testing your connection

Before diving into a long chat, sanity-check the endpoint from a terminal so you know the problem is not on SillyTavern's side:

curl https://api.example.com/v1/chat/completions \
  -H "Authorization: Bearer sk-your-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-4-6",
    "messages": [{"role": "user", "content": "Say hello in one sentence."}]
  }'

A clean JSON reply with a choices array means the endpoint and key are good, and any remaining issue is a SillyTavern setting (usually the wrong source type or a stray slash in the URL).

Doing it without a foreign credit card

This is where many international users get stuck. Anthropic and OpenAI both want a US/EU-style card and, in some regions, are hard to sign up for at all. An OpenAI-compatible relay solves both problems: you top up once, get a single sk- key, and it works for every model. When choosing one, look for a real official upstream (so replies are not degraded), streaming support, and a payment method you can actually use.

Safa API fits this exact use case for SillyTavern users. It exposes one OpenAI-compatible endpoint that covers Claude, GPT, and Gemini, so you paste a single base URL and key and switch models from the dropdown. It needs no credit card, accepts Alipay, supports prompt caching to keep long-session costs down, and generally runs at a lower price than paying each vendor directly. For anyone who just wants their character cards talking to Claude or GPT without fighting a payment wall, it removes the friction that stops most setups cold.

Whatever relay you pick, the SillyTavern side never changes: Chat Completion → Custom (OpenAI-compatible) → base URL + key → Connect. Get that right once and every model is a dropdown away.

Frequently Asked Questions

Why does SillyTavern say "connection error" or return a 404?

Almost always the base URL. Make sure it ends in /v1 with no trailing slash, that you selected Custom (OpenAI-compatible) as the source, and that the key has no extra spaces. Test with the curl command above to confirm the endpoint itself works.

Can I use Claude, GPT, and Gemini from one SillyTavern connection?

Yes, if your endpoint is a multi-model OpenAI-compatible relay. Configure the connection once, then change the model name in the dropdown to switch between Claude, GPT, and Gemini without re-entering keys.

Is there a way to set this up without a credit card?

Yes. Use a relay that accepts local payment methods such as Alipay and issues a standard sk- key, like Safa API. You top up once and point SillyTavern's custom endpoint at it — no foreign card required.

立即开始使用 Safa API API 中转

官方直连 · 一个接口接入 Claude / GPT / Gemini · 7×24 稳定

免费注册试用 →