Skip to content

Fix/openclaw determine api type#13397

Open
DDU1222 wants to merge 38 commits intoCherryHQ:mainfrom
DDU1222:fix/openclaw-determine-api-type
Open

Fix/openclaw determine api type#13397
DDU1222 wants to merge 38 commits intoCherryHQ:mainfrom
DDU1222:fix/openclaw-determine-api-type

Conversation

@DDU1222
Copy link
Contributor

@DDU1222 DDU1222 commented Mar 11, 2026

What this PR does

Before this PR:

After this PR:

Fixes #

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

The following tradeoffs were made:

The following alternatives were considered:

Links to places where the discussion took place:

Breaking changes

If this PR introduces breaking changes, please describe the changes and the impact on users.

Special notes for your reviewer

Checklist

This checklist is not enforcing, but it's a reminder of items that could be relevant to every PR.
Approvers are expected to review this list.

Release note


zhaochenxue and others added 30 commits May 27, 2025 17:40
…resolution

The previous implementation incorrectly used provider.anthropicApiHost
to determine API protocol, causing all models on mixed providers (aihubmix,
dmxapi, etc.) to be misidentified as anthropic-messages. Replace the
if-else chain with declarative mapping tables (endpoint_type, provider type,
provider id) and model name inference fallback. Also fix aihubmix OAuth
URL (path change + leading space), add support for all 8 OpenClaw protocols,
and add 22 unit tests covering all priority levels and the original bug.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: chenxue <DDU1222@users.noreply.github.com>
Model name inference (Step 4) was too aggressive — it matched model names
like "gemini" or "claude" on ALL providers, causing openrouter (which
proxies everything via OpenAI-compatible API) to get wrong protocols.

Now Step 4 only infers anthropic-messages when the provider has a dedicated
Anthropic endpoint (anthropicApiHost is set). Providers without it (e.g.
openrouter) always fall through to the default openai-completions.

Also removes unused isGeminiModel — no provider has a separate Gemini
endpoint, so gemini models on aggregators should use openai-completions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: chenxue <DDU1222@users.noreply.github.com>
The native Google Gemini provider (type: 'gemini') was missing from
PROVIDER_TYPE_TO_OPENCLAW_API, causing it to fall through to the
default openai-completions instead of google-generative-ai.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: chenxue <DDU1222@users.noreply.github.com>
Add geminiApiHost field to Provider type and configure it for aihubmix.
Step 4 now checks each vendor-specific host independently:
- anthropicApiHost → claude models use anthropic-messages
- geminiApiHost → gemini models use google-generative-ai

This ensures only providers that explicitly support a vendor's native API
will route models to that protocol. Providers like dmxapi (anthropicApiHost
only) won't accidentally route gemini models to google-generative-ai.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: chenxue <DDU1222@users.noreply.github.com>
getBaseUrlForApiType now uses provider.geminiApiHost when the API type
is google-generative-ai, ensuring the correct endpoint is written to
openclaw.cherry.json. Also fix AihubmixAPIClient test that was missing
geminiApiHost in the mock provider.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: chenxue <DDU1222@users.noreply.github.com>
…PIClient

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: chenxue <DDU1222@users.noreply.github.com>
Existing aihubmix providers stored in Redux lack the geminiApiHost field.
Add a migration to inject the default value, matching the pattern used
for anthropicApiHost in migration 172. Also add a fallback in
AihubmixAPIClient to prevent undefined errors for edge cases.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: chenxue <DDU1222@users.noreply.github.com>
- Update aihubmix geminiApiHost from /gemini to /gemini/v1beta in
  providers config and migration 200
- Add migration 201 to fix geminiApiHost for users who already ran
  migration 200 with the old URL
- Revert AihubmixAPIClient to use hardcoded gemini URL (not provider field)
- Bump persist version to 201

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: chenxue <DDU1222@users.noreply.github.com>
DDU1222 and others added 3 commits March 11, 2026 21:03
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: chenxue <DDU1222@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: chenxue <DDU1222@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: chenxue <DDU1222@users.noreply.github.com>
@DDU1222 DDU1222 requested a review from 0xfullex as a code owner March 11, 2026 13:06
@kangfenmao kangfenmao requested a review from DeJeune March 11, 2026 13:21
return state
}
},
'200': (state: RootState) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里两个版本可以合并一下

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