A loopback server is reachable by programs on the same computer. An LM Studio API token gives a local script a credential to present when the model server requires authentication.
Serve on Local Network controls which machines can reach the server. Require Authentication separately controls whether a reachable client must send a valid token. For scripts on the same computer, the server can stay on loopback with authentication enabled.
An LM Studio token grants general API access. The two extra permissions govern whether requests authenticated with that token can use MCP servers. A script that lists models only needs baseline access, and the model list can be empty.
Steps to create an API token in LM Studio:
- Open App Settings from the gear at the bottom of the sidebar.
API tokens require LM Studio 0.4.0 or later. The model server should be stopped before changing its authentication settings.
Related: How to stop the LM Studio server - Select Developer in the settings sidebar.

- Set Developer mode to ON.

- Close App Settings with the X in its upper-right corner.

- Open Model Server from the sidebar.

- Open Server Settings in the Local Server pane.

- Confirm that Serve on Local Network is off in Server Settings.
Turning on Require Authentication cuts off API clients that connect without a valid token. Those clients need a token before they can make requests again.
- Turn on Require Authentication in Server Settings.

- Open Manage Tokens beside Active API Keys.

- Select Create new token in the LM Studio API Tokens dialog.

- Enter a name such as local to identify the client that will use the token.

- Set Allow per-request remote MCP servers to Deny.

- Confirm that Allow calling servers from mcp.json is set to Deny.
If the row shows Allow, select Deny before creating the token.
- Select Create token.

- Copy the token using the copy control in the Token Created dialog.
LM Studio displays the full value once. Anyone who obtains it can make requests with its permissions while the server is reachable.
- Store the token in a password manager or your application's secret store.
If you lose or expose the value, create a replacement in Manage Tokens for clients that need it. Revoking the old token ends access for every client still using it. The trash button beside the token opens the Revoke confirmation.
- Dismiss Token Created with Done.
- Close LM Studio API Tokens with the X in its upper-right corner.

- Start the server with the Status switch in the Local Server pane.

- Confirm that Reachable at shows http://127.0.0.1:1234.
Use the displayed port in both requests if it differs from 1234.
Related: How to set the LM Studio server port - Send a model-list request without a token from a Bash shell on the same computer.
curl --disable --noproxy '*' --silent --show-error --include \ --max-time 10 http://127.0.0.1:1234/api/v1/models
- Confirm that the request without a token returns HTTP/1.1 401 Unauthorized.
Do not enter the token until this request returns HTTP 401. If you get HTTP 200, stop the server, turn on Require Authentication in Server Settings, and start the server again. If curl cannot connect, check that Status shows Running and the port matches Reachable at. For any other HTTP status, check that you're reaching LM Studio at the displayed port and that the URL ends in /api/v1/models. After correcting the setting or URL, repeat the request without a token.
- Start the concealed token prompt in the same Bash shell.
( set +x IFS= read -rs -p 'API token: ' token || exit 1 printf '\n' >&2 printf 'Authorization: Bearer %s\n' "$token" | curl --disable --noproxy '*' --silent --show-error --include \ --max-time 10 --header @- http://127.0.0.1:1234/api/v1/models )The shell passes the Authorization: Bearer header to curl over standard input, keeping the token out of the command arguments and shell history.
- Paste the saved value at the API token: prompt.
Bash hides the value as you enter it.
- Press Enter to send the authenticated request.
- Confirm that the response is HTTP/1.1 200 OK with a models array.
An empty models array also confirms that the token works when there are no models to list. HTTP 401 with a token means the server did not accept the value.