How to Test LM Studio APIs from a Browser
LM Studio's local server is OpenAI-compatible and binds to localhost by default. What its CORS toggle and network-binding setting actually control, and where AlleForge Agent fits when a browser client can't reach it.
Run requests against LM Studio's local server from a browser-based API client, inspect the response, and understand where its CORS and network settings — which work differently than Ollama's — can get in the way.
Before you start
- LM Studio installed, with a model downloaded and loaded
- The local server started — from the app's Developer tab, or
lms server startfrom LM Studio's command-line tool - AlleForge open, ready to build a request
Start the local API
By default, LM Studio's server binds to localhost (127.0.0.1) on port 1234, giving you a base URL of http://localhost:1234/v1 that follows the OpenAI API shape. The port is configurable in server settings if you've changed it.
Send a request
curl http://localhost:1234/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "model-id",
"messages": [{ "role": "user", "content": "Say this is a test!" }],
"temperature": 0.7
}'Replace model-id with an identifier from your loaded models — GET http://localhost:1234/v1/models lists what's currently available, which is worth checking first since the exact id has to match. LM Studio also exposes /v1/completions (legacy, prompt-based) and /v1/embeddings.
Test it from the browser
curl runs outside a browser entirely, so no origin check applies to it. A browser-based client is different: before it can read a cross-origin response, the browser needs the server to explicitly allow the calling origin. The full mechanism is covered in why browser API clients can't reach localhost — what's specific to LM Studio is how that permission gets granted, which is not the same model Ollama uses.
LM Studio's local server has an explicit CORS setting in its Developer/server settings — described in its own documentation as something you enable "to allow applications from different origins to access the API." This is a direct toggle you set, not an origin allow-list you add specific domains to the way Ollama's OLLAMA_ORIGINS works.
Two separate settings are easy to conflate here, and they control different things:
- CORS governs whether a browser tab's JavaScript is allowed to read the response at all.
- "Serve on Local Network" governs whether the port is reachable from other devices — enabling it changes the bind address from
127.0.0.1to0.0.0.0(LM Studio's CLI equivalent:lms server start --bind 0.0.0.0). LM Studio's own documentation is direct about the tradeoff: any bind other than127.0.0.1exposes the server beyond localhost, and recommends turning on LM Studio's "Require Authentication" setting (a real API token checked via theAuthorizationheader) if you do.
Enabling one doesn't enable the other. A server reachable from your whole LAN (network binding) can still reject a browser tab's request to read the response (no CORS) — they're independent layers.
Where AlleForge Agent helps
Browser
↓
AlleForge
↓
AlleForge Agent
↓
localhost:1234 (LM Studio)Two ways to reach it, not one:
- Enable CORS in LM Studio's server settings, if that's an option in your environment — this permits the browser to read the response directly.
- Use AlleForge Agent when changing server settings isn't available to you (a shared or managed machine, for instance). Agent sends the request as a local process on your own machine, outside the browser's network stack — LM Studio's CORS setting is never consulted, because the request doesn't arrive as a cross-origin browser call in the first place.
Agent doesn't turn CORS on or off inside LM Studio — it's a separate path that avoids needing to.
Troubleshooting
| Symptom | Likely cause |
|---|---|
| Connection refused | Local server isn't started — start it from LM Studio's Developer tab or lms server start |
| 400 / model not found | The model value doesn't match a loaded model's id — call GET /v1/models to confirm the exact id |
| 401 Unauthorized | "Require Authentication" is enabled in server settings but no (or an invalid) Authorization token was sent |
| Generic network/CORS error in the browser console | CORS is off in server settings — enable it, or use Agent |
| Reachable from other devices but the browser tab still can't read the response | "Serve on Local Network" (binding) and CORS are separate settings — confirm CORS specifically is enabled |
What Agent does not do
Agent provides network access between your browser and your machine. It doesn't know which model is loaded, doesn't start or manage LM Studio, doesn't set or check its CORS/authentication settings for you, and doesn't do anything specific to language models — it's the same generic bridge AlleForge uses for any other localhost or private-network API.
Related guides
- Testing local AI APIs from a browser — the general CORS mechanism this guide builds on
- How to test Ollama APIs from a browser — the same problem against a different local server
- What AlleForge does and doesn't do for AI APIs — the full capability picture, including SSE and streaming limits
- Why browser API clients can't reach localhost
- AlleForge Agent
Sources
LM Studio's default server port and base URL, OpenAI-compatible endpoints, and example request format are sourced from LM Studio's official API documentation (lmstudio.ai/docs). The CORS setting, "Serve on Local Network" behavior and its binding change, and the "Require Authentication" option are sourced from LM Studio's official server-settings and serve-on-network documentation (lmstudio.ai/docs/developer/core/server), fetched directly for this guide.
See this in AlleForge
See AlleForge Agent