Skip to content

fix: add API key placeholders for LM Studio and Ollama in OpenClaw and Claude Code#13552

Merged
kangfenmao merged 3 commits intomainfrom
DeJeune/openclaw-apikey-placeholder
Mar 25, 2026
Merged

fix: add API key placeholders for LM Studio and Ollama in OpenClaw and Claude Code#13552
kangfenmao merged 3 commits intomainfrom
DeJeune/openclaw-apikey-placeholder

Conversation

@DeJeune
Copy link
Copy Markdown
Collaborator

@DeJeune DeJeune commented Mar 17, 2026

What this PR does

Before this PR:

  • LM Studio and Ollama clients would fail when trying to use Claude Code agent because the services rejected empty API keys, even though these providers don't require authentication.

After this PR:

  • OpenClawService and ClaudeCodeService now assign placeholder API key values for local providers that don't require real API keys (Ollama, LM Studio), allowing these providers to work with Claude Code agent.

Fixes #

Why we need it and why it was done in this way

The following tradeoffs were made:

  • Used provider ID as the placeholder value in ClaudeCodeService (matching the pattern in BaseService.validateAgentModels)
  • Used a lookup map in OpenClawService to support both provider ID and type-based fallback, with a final fallback to 'no-key-required'

The following alternatives were considered:

  • Modifying the SDK itself to skip API key validation for local providers (not feasible, SDK is external)
  • Using environment variables to indicate which providers don't need keys (more complex than simple placeholder assignment)

Links to places where the discussion took place:

Breaking changes

None.

Special notes for your reviewer

The fix follows the existing pattern established in BaseService.validateAgentModels() which already uses provider ID as a placeholder for keyless providers. The changes are minimal and focused on enabling these providers without affecting other functionality.

Checklist

Release note

NONE

…d Claude Code services

For local providers like LM Studio and Ollama that don't require authentication,
OpenClaw and Claude Code services need non-empty placeholder API key values.

- OpenClawService: Added NO_KEY_PLACEHOLDERS map to provide fallback values
- ClaudeCodeService: Separated apiKey validation from provider type check and added
  placeholder assignment logic matching BaseService.validateAgentModels pattern

Fixes clients attempting to use LM Studio/Ollama with Claude Code agent.

Signed-off-by: suyao <[email protected]>
@DeJeune DeJeune marked this pull request as draft March 17, 2026 13:47
@DeJeune DeJeune marked this pull request as ready for review March 25, 2026 10:25
@kangfenmao kangfenmao merged commit 7d7d4b9 into main Mar 25, 2026
6 checks passed
@kangfenmao kangfenmao deleted the DeJeune/openclaw-apikey-placeholder branch March 25, 2026 12:17
MyPrototypeWhat pushed a commit that referenced this pull request Mar 30, 2026
…d Claude Code (#13552)

### What this PR does

Before this PR:
- LM Studio and Ollama clients would fail when trying to use Claude Code
agent because the services rejected empty API keys, even though these
providers don't require authentication.

After this PR:
- OpenClawService and ClaudeCodeService now assign placeholder API key
values for local providers that don't require real API keys (Ollama, LM
Studio), allowing these providers to work with Claude Code agent.

Fixes #

### Why we need it and why it was done in this way

The following tradeoffs were made:
- Used provider ID as the placeholder value in ClaudeCodeService
(matching the pattern in BaseService.validateAgentModels)
- Used a lookup map in OpenClawService to support both provider ID and
type-based fallback, with a final fallback to 'no-key-required'

The following alternatives were considered:
- Modifying the SDK itself to skip API key validation for local
providers (not feasible, SDK is external)
- Using environment variables to indicate which providers don't need
keys (more complex than simple placeholder assignment)

Links to places where the discussion took place:
- https://lmstudio.ai/docs/developer/anthropic-compat
- https://docs.openclaw.ai/providers/ollama
- https://docs.ollama.com/api/anthropic-compatibility

### Breaking changes

None.

### Special notes for your reviewer

The fix follows the existing pattern established in
`BaseService.validateAgentModels()` which already uses provider ID as a
placeholder for keyless providers. The changes are minimal and focused
on enabling these providers without affecting other functionality.

### Checklist

- [x] PR: The PR description is expressive enough and will help future
contributors
- [x] Code: [Write code that humans can
understand](https://en.wikiquote.org/wiki/Martin_Fowler#code-for-humans)
and [Keep it simple](https://en.wikipedia.org/wiki/KISS_principle)
- [x] Refactor: You have [left the code cleaner than you found it (Boy
Scout
Rule)](https://learning.oreilly.com/library/view/97-things-every/9780596809515/ch08.html)
- [x] Upgrade: Impact of this change on upgrade flows was considered and
addressed if required
- [ ] Documentation: A [user-guide update](https://docs.cherry-ai.com)
was considered and is present (link) or not required. Check this only
when the PR introduces or changes a user-facing feature or behavior.
- [x] Self-review: I have reviewed my own code (e.g., via
[`/gh-pr-review`](/.claude/skills/gh-pr-review/SKILL.md), `gh pr diff`,
or GitHub UI) before requesting review from others

### Release note

```release-note
NONE
```

Signed-off-by: suyao <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants