Repository navigation
Add LM Studio API key auth support - #29
Merged
Merged
Conversation
trigger2k20
marked this pull request as ready for review
June 8, 2026 11:17
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dd4e5d53f7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Contributor
Author
|
@agustif i made an fork since you last version did not work. |
This was referenced Jun 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds API-key/Bearer-token support for LM Studio servers that require authentication while preserving the existing OpenCode LM Studio Plugin behavior:
/v1/modelsprovider.lmstudio.modelsaugmentationThe package is prepared as
opencode-lmstudio@0.3.1.Authentication behavior
Discovery, health checks, cache warmup, and runtime model validation now send:
Authorization: Bearer <token>when an API key is configured.
Supported configuration sources:
provider.lmstudio.options.apiKey{env:LM_API_TOKEN}LMSTUDIO_API_KEYLM_API_TOKENThe previous
OPENAI_API_KEYfallback was intentionally removed to avoid accidentally sending unrelated OpenAI credentials to LM Studio-compatible endpoints.Security hardening
Implicit environment fallback is restricted to local/private LM Studio URLs only:
localhost127.0.0.0/810.0.0.0/8172.16.0.0/12192.168.0.0/16169.254.0.0/16.localFor public or hosted OpenAI-compatible endpoints, users must configure
provider.lmstudio.options.apiKeyexplicitly. This avoids forwarding a local LM Studio token to a malicious or unintended publicbaseURLpurely because an environment variable exists.Model handling
/v1/modelsare skipped for OpenCode chat model registration.Packaging/runtime fix
The package entrypoint now exports built JavaScript from
distinstead of TypeScript source. This is required for OpenCode Desktop/package-cache loading and avoids relying on runtime TypeScript loading fromnode_modules.Tooling
The ESLint blocker in this fork is fixed by using ESLint 10.4.1 with flat config and adding the required TypeScript ESLint parser/plugin packages. The lockfile/dev-dependency churn is limited to making lint/build validation reproducible and generating the
distpackage artifact used at runtime.Validation
Validated locally:
Results:
consolewarnings onlydistartifactAdditional local OpenCode smoke test:
Result:
opencode-lmstudio0.3.1Review feedback addressed
fc,fd, orfe80do not receive implicit environment fallback tokens.Security review
A diff-scoped Codex Security review was run against
origin/main...HEAD. No reportable findings remain in the final diff after the environment-fallback hardening described above.