Before you wire an app to LocalAI, test the API directly. One curl request to the chat completions endpoint proves three things at once: the server is up, a model is loaded, and the OpenAI-compatible shape works. The LocalAI docs show the endpoint as POST /v1/chat/completions.
Check the model list first
curl http://localhost:8080/v1/models
This lists the models LocalAI can serve. Note the exact model name — the chat request must use that name, not the gallery display name.
Send a chat completion
curl http://localhost:8080/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"model": "llama-3.2-1b-instruct", "messages": [{"role": "user", "content": "Reply with one sentence saying you are ready."}]}'
If you set an API key, add -H "Authorization: Bearer YOUR_KEY" to the request — newer LocalAI versions require credentials on routes that are not on the public list. The reply is JSON; the model’s text is in choices[0].message.content. Pipe it through jq to read it cleanly: append | jq '.choices[0].message.content'.
| Check | What you should see | If you do not see it |
|---|---|---|
| Models list | GET /v1/models returns your model | LocalAI is not running, or no model is installed |
| Chat replies | The JSON contains choices[0].message.content | The model name is wrong, or the model is still loading |
| Auth error | A 401 means a key is required — add the Bearer header | Sending the request without a key when an API key is set |
Expected result. We checked the LocalAI text-and-retrieval docs for the /v1/chat/completions endpoint and the /v1/models list, and the install docs for the http://localhost:8080 address. We did not run LocalAI, so the request above is UNTESTED on this machine.
Limits
A successful curl test proves the API works; it does not prove the model’s answers are good. Keep the test prompt fixed when you compare models, and never put a real API key into a shared script or screenshot.
Sources
- LocalAI Text and retrieval — Chat completions: POST /v1/chat/completions; curl http://localhost:8080/v1/chat/completions; curl http://localhost:8080/v1/models
- LocalAI Install — open http://localhost:8080 after starting LocalAI
Sources checked 2026-11-28.
