New Tool Radar

Local AI

How to Send a Chat Completion to GPT4All’s Server With curl

Send a chat completion to GPT4All's local server with curl and read the reply, the quickest check that the server works.

Schematic diagram with four steps: enable the server, load a model, send the chat completion with curl, then read the reply from the choices array.

The fastest way to check GPT4All’s server is a curl call: one POST to /v1/chat/completions with a model and a message, and the reply tells you whether the server, the model and the API all work.

POST the chat completion

Enable the local server in Settings and load a model, then run: curl http://localhost:4891/v1/chat/completions -H "Content-Type: application/json" -d '{"model": "<model-name>", "messages": [{"role": "user", "content": "Say hello"}]}'. The model name must be exactly what GET /v1/models reports. The reply carries the model’s message in the choices array.

curl http://localhost:4891/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{"model": "<model-name>", "messages": [{"role": "user", "content": "Say hello"}]}'

If the call fails, check the pieces in order: is the server enabled, is a model loaded, is the port 4891, and is the model name exact? A 404 usually means the model name is wrong; a connection refused means the server is not running.

Try it: four checks

Check What you should see If you do not see it
Server on The local server is enabled in Settings Port 4891, localhost
Model loaded A model is loaded in GPT4All Check /v1/models lists it
Call succeeds The curl call returns a reply Check the model name spelling
Reply sensible The message answers the prompt Try a simpler prompt if not

Expected result. We checked the GPT4All Local API Server wiki, which documents POST /v1/chat/completions and the GET /v1/models endpoint for the exact model name. We did not call the API on this machine.

Limits

This guide covers the curl call only. The model name must match the server’s list exactly. We did not test any call ourselves.

Sources

See all