Documentation
LM Studio REST API
LM Studio REST API
LM Studio supports API Tokens for authentication, providing a secure and convenient way to access the LM Studio API.
By default, LM Studio does not require authentication for API requests. 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. See usage below.

Enable authentication to require valid API tokens for all requests

Managing tokens in the server settings
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.

API Tokens Modal
Create a token by clicking on the Create Token button. Provide a name for the token and select the desired permissions.

Creating an API Token
Once created, make sure to copy the token as it will not be shown again.

API token created
To edit the permissions of an existing API Token, click on the Edit button next to the token in the API Tokens modal. You can modify the name and permissions of the token.

Editing an API Token
The example below requires allowing calling servers from mcp.json to be enabled and the tiktoken MCP in mcp.json.
curl -X POST \ http://localhost:1234/api/v1/chat \ -H "Authorization: Bearer $LM_API_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "model": "ibm/granite-4-micro", "input": "What is the first line in the tiktoken documentation?", "integrations": [ { "type": "plugin", "id": "mcp/tiktoken", "allowed_tools": [ "fetch_tiktoken_documentation" ] } ] }'
To use API tokens with the Python SDK, see the Python SDK guide.
To use API tokens with the TypeScript SDK, see the TS SDK guide.
This page's source is available on GitHub
On this page
Require Authentication for each request
Creating API Tokens
Configuring API Token Permissions
API Token Usage
Using API Tokens with REST API
Using API Tokens with Python SDK
Using API Tokens with TypeScript SDK