Skip to content

fix: write api_key auth profiles for key providers (OpenClaw 2026.6.8 compat) - #214

Merged
KrasimirKralev merged 1 commit into
ID-Robots:betafrom
KrasimirKralev:fix/openrouter-auth-api-key
Jun 19, 2026
Merged

KrasimirKralev merged 1 commit into
ID-Robots:betafrom
KrasimirKralev:fix/openrouter-auth-api-key

Conversation

@KrasimirKralev

Copy link
Copy Markdown
Contributor

Problem

On OpenClaw 2026.6.8, OpenRouter (and anthropic/openai/google) chats fail with:

[agent/embedded] embedded run agent end: ... provider=openrouter
  error=LLM request failed. rawError=401 Missing Authentication header

ClawBox writes these key-based providers' auth as type: "token" profiles, and OpenRouter's models.providers.openrouter.apiKey as the placeholder "openrouter-ref" (a reference the old gateway resolved from the profile). OpenClaw 2026.6.6 honored that; 2026.6.8 reworked auth resolution — it no longer turns a token-mode profile into an Authorization header, and it sends models.providers.*.apiKey verbatim. So "openrouter-ref" went out as the bearer → 401.

Fix

Write the same type: "api_key" shape the already-working providers (clawai/ollama/llamacpp) use, and inline OpenRouter's real key:

  • auth-profiles.json else branch: type:"token"/token:type:"api_key"/key:
  • openclaw.json auth.profiles.<key> mode: … : tokensubscription ? oauth : api_key (de-special-cases the per-provider guard)
  • OpenRouter providerDef: apiKey:"openrouter-ref"apiKey: <real key> (mirrors the clawai/deepseek providerDefs)

Covers all key-based providers, not just OpenRouter, since they all hit the same branch.

Verification

  • End-to-end on device (Jetson, OpenClaw 2026.6.8): applied this exact config shape by hand → gateway reloaded, openrouter/anthropic/claude-haiku-4.5 loaded, 401 gone, key validates against OpenRouter /auth/key (200).
  • Unit tests updated: anthropic profile now asserts api_key+key; OpenRouter test asserts the inlined real key (not openrouter-ref) + api_key profile.

Follow-up (not this PR)

configure/route.ts could extract a writeApiKeyProfile() helper to collapse the four now-identical api_key branches and migrate to openclaw onboard --auth-choice <provider>-api-key (the schema-robust canonical path the in-file comment already flags). Kept out of scope to keep this fix minimal.

… compat)

OpenRouter/anthropic/openai/google chats failed with '401 Missing
Authentication header' on OpenClaw 2026.6.8. ClawBox wrote their auth as
type:"token" profiles (and OpenRouter's provider apiKey as the placeholder
"openrouter-ref"); 2026.6.6 resolved those, but 2026.6.8 reworked auth
resolution and no longer turns a token-mode profile into an Authorization
header, nor resolves the placeholder — it sends models.providers.*.apiKey
verbatim. Write the same type:"api_key" shape the working providers
(clawai/ollama/llamacpp) use, and inline OpenRouter's real key. Verified
end-to-end on device against 2026.6.8.
@KrasimirKralev
KrasimirKralev requested a review from a team as a code owner June 18, 2026 13:19
@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@KrasimirKralev, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 17 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: fb7229a7-9632-4a6f-a931-849772b59471

📥 Commits

Reviewing files that changed from the base of the PR and between 79fdc62 and c075de3.

📒 Files selected for processing (2)
  • src/app/setup-api/ai-models/configure/route.ts
  • src/tests/routes/ai-models/configure.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

1 participant