# Authentication

Using API Tokens in LM Studio

##### Requires LM Studio 0.4.0 or newer. [Link to section requires-lm-studio-040-or-newer](/content/docs/developer/core/authentication#requires-lm-studio-040-or-newer/index.html)

LM Studio supports API Tokens for authentication, providing a secure and convenient way to access the LM Studio API.

### Require Authentication for each request [Link to section require-authentication-for-each-request](/content/docs/developer/core/authentication#require-authentication-for-each-request/index.html)

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.

Info

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](/content/docs/developer/core/authentication#api-token-usage/index.html).

### Creating API Tokens [Link to section creating-api-tokens](/content/docs/developer/core/authentication#creating-api-tokens/index.html)

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.

### Configuring API Token Permissions [Link to section configuring-api-token-permissions](/content/docs/developer/core/authentication#configuring-api-token-permissions/index.html)

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.

## API Token Usage [Link to section api-token-usage](/content/docs/developer/core/authentication#api-token-usage/index.html)

### Using API Tokens with REST API: [Link to section using-api-tokens-with-rest-api](/content/docs/developer/core/authentication#using-api-tokens-with-rest-api/index.html)

Note

The example below requires [allowing calling servers from mcp.json](/content/docs/developer/core/server/settings/index.html) to be enabled and the [Playwright MCP](https://github.com/microsoft/playwright-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 '{\n    "model": "ibm/granite-4-micro",\n    "input": "Open lmstudio.ai",\n    "integrations": [\
      {\
        "type": "plugin",\
        "id": "mcp/playwright",\
        "allowed_tools": ["browser_navigate"]\
      }\
    ],\n    "context_length": 8000\n  }'
```

### Using API Tokens with Python SDK [Link to section using-api-tokens-with-python-sdk](/content/docs/developer/core/authentication#using-api-tokens-with-python-sdk/index.html)

To use API tokens with the Python SDK, see the [Python SDK guide](/content/docs/python/getting-started/authentication/index.html).

### Using API Tokens with TypeScript SDK [Link to section using-api-tokens-with-typescript-sdk](/content/docs/developer/core/authentication#using-api-tokens-with-typescript-sdk/index.html)

To use API tokens with the TypeScript SDK, see the [TS SDK guide](/content/docs/typescript/authentication/index.html).

[Server Settings\n\nConfigure server settings for LM Studio API Server](/content/docs/developer/core/server/settings/index.html) [Setup llmster as a Startup Task on Linux\n\nConfigure llmster to run on startup using systemctl on Linux](/content/docs/developer/core/headless_llmster/index.html)

### On this page

[Requires LM Studio 0.4.0 or newer.](/content/docs/developer/core/authentication#requires-lm-studio-040-or-newer/index.html) [Require Authentication for each request](/content/docs/developer/core/authentication#require-authentication-for-each-request/index.html) [Creating API Tokens](/content/docs/developer/core/authentication#creating-api-tokens/index.html) [Configuring API Token Permissions](/content/docs/developer/core/authentication#configuring-api-token-permissions/index.html) [API Token Usage](/content/docs/developer/core/authentication#api-token-usage/index.html) [Using API Tokens with REST API:](/content/docs/developer/core/authentication#using-api-tokens-with-rest-api/index.html) [Using API Tokens with Python SDK](/content/docs/developer/core/authentication#using-api-tokens-with-python-sdk/index.html) [Using API Tokens with TypeScript SDK](/content/docs/developer/core/authentication#using-api-tokens-with-typescript-sdk/index.html)
