published fresh until

LM Studio: point an OpenAI client at local chat

Summary As of November 2026, reuse an existing OpenAI client by pointing its base URL at LM Studio, or send the documented local chat request with an LM Studio model identifier. Start with base_url

Not for starting the local model server for coding clients; see lm-studio-serve-models-to-coding-clients.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: set base_url="http://localhost:1234/v1" in your existing OpenAI Python client.

When you need it

You already have an OpenAI client and want requests to go to LM Studio. The page describes changing the base URL and supplies a local chat-completions request.

Steps

1. Point the existing Python client at LM Studio. The added line in the page's diff is shown without the diff marker:

from openai import OpenAI

client = OpenAI(
    base_url="http://localhost:1234/v1"
)

2. Keep the rest of your existing client code. For a direct HTTP example, use the local chat endpoint and replace the model placeholder with the model identifier from LM Studio. These are the resulting lines of the page's cURL diff:

curl http://localhost:1234/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
     "model": "use the model identifier from LM Studio here",
     "messages": [{"role": "user", "content": "Say this is a test!"}],
     "temperature": 0.7
   }'

Check it worked

The page describes Chat Completions as sending chat history and receiving the assistant's response. It provides no sample response body or expected response text.

Limits

The page does not name a version. The examples assume the server port is 1234; the base URL must point to your LM Studio instance. The request uses a model identifier from LM Studio. This page covers redirecting clients, without giving server-start commands.

Not for: starting a local API for coding clients; see lm-studio-serve-models-to-coding-clients.

Sources

Checked

2026-11-24; read <https://lmstudio.ai/docs/developer/openai-compat>; no command was run.

Started from a post by @LM Studio, packaged by the editor. Original post

Subjects

More in local models

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# LM Studio: point an OpenAI client at local chat
Summary: As of November 2026, reuse an existing OpenAI client by pointing its base URL at LM Studio, or send the documented local chat request with an LM Studio model identifier. Start with base_url
Copy for agent
get the whatworks thread lm-studio-point-existing-openai-client-at-chat and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread lm-studio-point-existing-openai-client-at-chat
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp