New Tool Radar

Local AI

How to Ask Text Generation WebUI’s Model from Another App with Its API

Start Text Generation WebUI with the --api flag, then send a chat request to its OpenAI-compatible API so another app can use the loaded model.

Schematic diagram with three boxes: Text Generation WebUI started with the api flag, the API on port 5000, and a curl chat request returning a reply from the loaded model.

Text Generation WebUI (TextGen) is a desktop app for local LLMs with a chat interface in the browser — but the model inside it can also answer other programs. It has an OpenAI/Anthropic-compatible API, with chat, completions, and messages endpoints, so you can use it as a local drop-in replacement for the OpenAI or Anthropic APIs. The catch is that the API is off until you ask for it: nothing listens for API requests unless the app is started with the --api flag, and a model must be loaded first.

Start the app with the API on

Load a model in the app first — download a GGUF model file from Hugging Face, place it in the user_data/models folder, and load it from the Model tab. Then start the server with the API enabled. From the portable install:

python server.py --portable --api --auto-launch

The --api flag enables the API server, and --api-port sets its listening port. If you use the one-click installer instead, pass the flag directly, for example ./start_linux.sh --api, or persist it in user_data/CMD_FLAGS.txt.

Ask the loaded model with curl

With the API on, the server listens for OpenAI-format requests. Send a chat completion request, using the name of the model you loaded as the model value:

curl http://localhost:5000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "YOUR_LOADED_MODEL",
    "messages": [{"role": "user", "content": "Say hello in five words."}]
  }'
Check What you should see If you do not see it
API answers A reply of five words from the loaded model Connection refused means the app was started without –api
Model name The reply comes from the model loaded in the UI The model value must match the loaded model — check the Model tab
Web UI The chat UI still works at http://127.0.0.1:7860 The app did not start — read the terminal output

Expected result. We checked the TextGen README for the API flag and the launch command. We did not run Text Generation WebUI or send a request.

Limits

The port 5000 default above comes from a third-party install guide, not from the project README, so confirm it with --api-port on your installed version — the README documents the flag but does not state its default. The API key is off by default and is only set at launch with --api-key, so anyone on your computer can call the API unless you set one. TextGen says it is 100% offline and private, with no telemetry, but that applies to the local model: extensions and web search features are separate and may reach the network. We did not run Text Generation WebUI, so no reply here is a recorded result.

Sources

See all