Text Generation WebUI is a chat interface, but it can also be an API server: with the API flag on, other apps can call your local model through OpenAI-compatible Chat and Completions endpoints, including tool-calling support.
Enable the API
Add the --api flag when you start the server. With the portable route:
python server.py --portable --api --auto-launch
With the one-click installer, pass the flag to the start script (./start_linux.sh --api), or make it permanent by adding --api to user_data/CMD_FLAGS.txt — the README says flags added there persist across restarts. A model must be loaded before the API can answer: start the UI, load a model, then call the API.
Test it from another app
Point an OpenAI-compatible client at the local server’s base URL and send a chat completion with the loaded model’s name. If the client gets an empty reply or an error, check two things: the flag was actually passed (look at the startup log for the API line), and a model is loaded. The API listens on localhost by default, so only programs on the same machine can reach it — that is a safety feature, not a bug. To let another device call it, you would need the listen flag and access control, which is outside this guide.
| Check | What you should see | If you do not see it |
|---|---|---|
| API enabled | The server starts with –api in its flags | The flag was added to the wrong file — use user_data/CMD_FLAGS.txt for persistence |
| Model loaded | A model is loaded in the UI | The API cannot answer without a loaded model |
| Client gets a reply | An OpenAI-compatible client receives text | The base URL or model name is wrong — check both |
Expected result. We checked the text-generation-webui README for the OpenAI-compatible API with Chat and Completions endpoints, the --api flag, the CMD_FLAGS.txt persistence, and the portable launch command. We did not run the app, so the steps above are UNTESTED on this machine.
Limits
The API serves the one loaded model; switching models means loading another in the UI. API access is local by default — do not expose it to a network without access control in front of it.
Sources
- text-generation-webui README — OpenAI-compatible API with Chat and Completions endpoints, including tool-calling support; –api to enable the API; add flags to user_data/CMD_FLAGS.txt; python server.py –portable –api –auto-launch
- Text Generation WebUI guide — OpenAI-compatible API extension so other apps can connect to your local model without code changes
Sources checked 2026-11-28.
