Documentation
Core
LM Studio REST API
OpenAI Compatible Endpoints
Anthropic Compatible Endpoints
Core
LM Studio REST API
OpenAI Compatible Endpoints
Anthropic Compatible Endpoints
POST/v1/messagescurl http://localhost:1234/v1/messages \ -H "Content-Type: application/json" \ -H "x-api-key: $LM_API_TOKEN" \ -d '{ "model": "ibm/granite-4-micro", "max_tokens": 256, "messages": [ {"role": "user", "content": "Say hello from LM Studio."} ] }'
If you have not enabled Require Authentication, the x-api-key header is optional.
curl http://localhost:1234/v1/messages \ -H "Content-Type: application/json" \ -H "x-api-key: $LM_API_TOKEN" \ -d '{ "model": "ibm/granite-4-micro", "messages": [{"role": "user", "content": "Hello"}], "max_tokens": 256, "stream": true }'
You will receive SSE events such as message_start, content_block_start, content_block_delta, content_block_stop, message_delta, and message_stop.
curl http://localhost:1234/v1/messages \ -H "Content-Type: application/json" \ -H "x-api-key: $LM_API_TOKEN" \ -d '{ "model": "ibm/granite-4-micro", "max_tokens": 1024, "tools": [ { "name": "get_weather", "description": "Get the current weather in a given location", "input_schema": { "type": "object", "properties": { "location": { "type": "string", "description": "The city and state, e.g. San Francisco, CA" } }, "required": ["location"] } } ], "tool_choice": {"type": "any"}, "messages": [ { "role": "user", "content": "What is the weather like in San Francisco?" } ] }'
This page's source is available on GitHub
On this page