openclaw - 💡(How to fix) Fix [Bug]: LM Studio Provider Fails: Environment Variable Expansion + API Endpoint Mismatch [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#80495Fetched 2026-05-11 03:14:05
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
2
Author
Timeline (top)
cross-referenced ×2labeled ×2commented ×1

OpenClaw's LM Studio provider fails due to two critical issues:

Environment variables ($LMSTUDIO_API_KEY) not expanded in API calls API endpoint incompatibility (uses /v1/chat/completions but LM Studio's OpenAI-compatible API returns HTTP 200 with errors)

Error Message

  1. Observe 401 error with literal string $LMSTUDIO_API_KEY
  • Attempts to use /v1/chat/completions which LM Studio returns HTTP 200 with error: "Unexpected endpoint or method

Root Cause

OpenClaw's LM Studio provider fails due to two critical issues:

Environment variables ($LMSTUDIO_API_KEY) not expanded in API calls API endpoint incompatibility (uses /v1/chat/completions but LM Studio's OpenAI-compatible API returns HTTP 200 with errors)

RAW_BUFFERClick to expand / collapse

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

OpenClaw's LM Studio provider fails due to two critical issues:

Environment variables ($LMSTUDIO_API_KEY) not expanded in API calls API endpoint incompatibility (uses /v1/chat/completions but LM Studio's OpenAI-compatible API returns HTTP 200 with errors)

Steps to reproduce

  1. Configure LM Studio provider in openclaw.json with apiKey: "$LMSTUDIO_API_KEY"
  2. Set environment variable LMSTUDIO_API_KEY with valid token
  3. Attempt to use any LM Studio model
  4. Observe 401 error with literal string $LMSTUDIO_API_KEY

Expected behavior

  • Environment variables should be expanded before sending API requests
  • Should detect and use LM Studio's working endpoints (/api/v1/chat for native API or /v1/completions for OpenAI-compatible)

Actual behavior

  • $LMSTUDIO_API_KEY sent literally, causing 401 errors
  • Attempts to use /v1/chat/completions which LM Studio returns HTTP 200 with error: "Unexpected endpoint or method

OpenClaw version

2026.5.7

Operating system

Linux (containerized)

Install method

docker

Model

google/gemma-4-26b-a4b

Provider / routing chain

openclaw -> LM Studio

Additional provider/model setup details

Additional Context:

  • LM Studio has functional native API at /api/v1/chat (different format)
  • LM Studio's OpenAI-compatible API at /v1/chat/completions is buggy (returns 200 with errors)
  • LM Studio's old OpenAI completions API at /v1/completions works but uses deprecated format
  • Other providers (OpenRouter, Gemini) properly expand environment variables

Proposed Solutions:

  • Fix environment variable expansion in LM Studio provider
  • Add support for LM Studio's native API (/api/v1/chat)
  • Implement endpoint fallback logic for LM Studio's inconsistent API

Logs, screenshots, and evidence

Impact and severity

  • Priority: High - prevents users from using local LM Studio inference with OpenClaw

Additional information

Related Links:

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

  • Environment variables should be expanded before sending API requests
  • Should detect and use LM Studio's working endpoints (/api/v1/chat for native API or /v1/completions for OpenAI-compatible)

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix [Bug]: LM Studio Provider Fails: Environment Variable Expansion + API Endpoint Mismatch [1 comments, 2 participants]