New Tool Radar

Local AI

How to Call a Running mlx_lm Server With curl

Send a chat request to a running mlx_lm server with curl and confirm it returns a reply.

Schematic with three steps: Start the server; Send a chat request with curl; Check the reply.

mlx_lm.server turns a local model into an HTTP API that is compatible with the OpenAI chat API, running on localhost:8080 by default. A curl request is the quickest way to confirm the server answers before you wire an app into it.

What you need

  • A Mac with Apple Silicon and mlx-lm installed
  • A downloaded MLX model
  • The server already started with mlx_lm.server –model

Step 1: Start the server

Run mlx_lm.server –model with your model, for example mlx-community/Mistral-7B-Instruct-v0.3-4bit. The server defaults to running on localhost:8080.

Step 2: Send a chat request with curl

In a second terminal, send a chat completions request to http://localhost:8080/v1/chat/completions with the model name and a short user message.

Step 3: Check the reply

Read the response and confirm it carries a chat reply from your model. If the request fails, check the server is still running and the model name matches the one you started.

Worked example: synthetic server call

The table below is a synthetic example. It shows the expected result of calling the server; no server was called.

Check Expected Result
Server starts Listening on localhost:8080 Pass
curl chat request Reply received Pass
Reply content Answers the message Pass

Expected result (UNTESTED). the server starts on localhost:8080, the curl request returns a reply, and the reply answers the message sent. This check was not run live; the table shows the expected result for the synthetic example.

Limits

  • The server is not recommended for production, because its security is basic; keep it on localhost.
  • The model name in the request must match the model the server was started with.
  • Starting the server downloads the model on first use, so the first start needs the internet.

Sources

See all