LM Studio’s local server does not require authentication by default. That is fine while it only listens on your own computer, but before you share the server — for example, by serving it on your local network — turn on authentication and create an API token. LM Studio’s own docs say the server does not require authentication by default, and that you can configure it to require authentication by API token in the server settings for added security.
Turn on Require Authentication
This needs LM Studio 0.4.0 or newer. To enable authentication so that only requests with a valid API token are accepted, toggle the switch in the Developers Page > Server Settings. Once enabled, all requests made through the REST API, Python SDK, or TypeScript SDK will need to include a valid API token.
Create a token and keep it safe
To create API tokens, click on Manage Tokens in the Server Settings. It will open the API Tokens modal where you can create, view, and delete API tokens. Create a token by clicking on the Create Token button, provide a name for the token, and select the desired permissions. Once created, make sure to copy the token, as it will not be shown again. Treat the token like a password: anyone who has it can use your server, and you cannot look it up again later — if you lose it, delete it and create a new one.
Try it: one request without the token, one with it
Send a request to your server twice and compare the results. Without a token, the request should be refused; with the token in the Authorization header, it should be accepted. LM Studio’s docs give the authenticated form as:
curl -X POST \
http://localhost:1234/api/v1/chat \
-H "Authorization: Bearer $LM_API_TOKEN" \
-H "Content-Type: application/json"
| Request | Header sent | Expected result |
|---|---|---|
| Without a token | No Authorization header |
Refused — authentication is required |
| With a token | Authorization: Bearer $LM_API_TOKEN |
Accepted — the server answers |
If the request without a token is refused and the one with the token is accepted, authentication is working. If both are accepted, the switch is still off. Expected result. We checked the LM Studio authentication docs and the LM Studio API quickstart. We did not run the LM Studio server or send a request to it.
Limits
A token proves a request was allowed to reach the server; it does not encrypt the connection, and it does not make a server safe to expose to the whole internet. The docs describe creating tokens in the app’s interface only, so this step needs the desktop app. Keep the token out of shared files and screenshots, and delete tokens you no longer use in the same Manage Tokens modal. We did not run the LM Studio server, so no refusal or acceptance here is a recorded result.
