Repository navigation
feat(workbench): show a /v1 example base for custom OpenAI-compatible endpoints - #7547
Conversation
…oints Custom OpenAI-family endpoints (Chat Completions, Responses, New API and Sub2API) had no Base URL example, so a bare host root looked as valid as a versioned base and model discovery failed against relays that serve `/v1/models` (apache#3320). These providers now advertise `https://api.example.com/v1` as a JSON Schema example derived from their runtime adapter, not their name. The connection form shows it as the placeholder and, when a bare host root is entered, notes that most services expect a base ending in `/v1`. The configured value stays authoritative and is never rewritten. Closes apache#3320 Generated-by: Claude Code
M4n5ter
left a comment
There was a problem hiding this comment.
English
Good direction overall — using JSON Schema examples without rewriting or blocking the configured URL is clean. One concrete bug and one small coupling to fix before merging:
-
Bug:
cloudflare-workers-aiaccidentally getshttps://api.example.com/v1and the/v1hint
Inplugins/agent/providers/src/api.rs(configuration_schema), the predicateself.facts.base_url.is_empty()+OpenaiChat | OpenaiResponses | OpenaiCompatiblealso matchescloudflare-workers-ai(baseUrl: "",runtimeAdapter.kind: "openai-compatible",modelDiscovery.kind: "cloudflare").
Cloudflare Workers AI actually requires an endpoint ending in/ai/v1(plugins/agent/providers/src/api/discovery/pages.rsrejects anything else with"Cloudflare endpoint must end with /ai/v1"), so advertisinghttps://api.example.com/v1and telling users to use/v1actively misleads them.- Guard the condition with
matches!(self.facts.model_discovery, facts::discovery::ModelDiscovery::Protocol { .. })so only OpenAI-protocol custom endpoints receive the generic/v1example. - Add
("cloudflare-workers-ai", None)tocustom_openai_endpoints_advertise_a_versioned_example_baseinplugins/agent/providers/tests/integration/api/mod.rs.
- Guard the condition with
-
Minor coupling between
bareRootExampleand the hardcoded/v1copy
bareRootExampleinproducts/maka/workbench/app/connectionEndpoint.tstriggers for any schemaexamplewith a non-empty path (apiPath(example)), whileConnectionForm.tsxhardcodes"Most OpenAI-compatible services expect a base URL ending in /v1, such as {example}.". If any future provider advertises a non-/v1example (e.g./ai/v1or/v2), the hint text will contradict the example. Either tighten the check (e.g.apiPath(example) === '/v1') or phrase the note generically without hardcodingOpenAI-compatible//v1.
简体中文
整体方向和实现很干净——复用 JSON Schema 的 examples 且不静默改写或拦截用户输入,思路是对的。合入前有一个实打实的漏网 bug 和一个小耦合需要修一下:
-
Bug:
cloudflare-workers-ai被误伤,拿到了错误的https://api.example.com/v1示例和/v1提示
plugins/agent/providers/src/api.rs(configuration_schema)里的判断条件self.facts.base_url.is_empty()加OpenaiChat | OpenaiResponses | OpenaiCompatible还会命中cloudflare-workers-ai(它的baseUrl也是"",runtimeAdapter.kind是"openai-compatible",但modelDiscovery.kind是"cloudflare")。
Cloudflare Workers AI 实际要求端点以/ai/v1结尾(plugins/agent/providers/src/api/discovery/pages.rs直接校验"Cloudflare endpoint must end with /ai/v1"),给它展示https://api.example.com/v1和/v1提示会直接误导用户。- 在
api.rs条件里补上matches!(self.facts.model_discovery, facts::discovery::ModelDiscovery::Protocol { .. })排除cloudflare-workers-ai; - 在
plugins/agent/providers/tests/integration/api/mod.rs的custom_openai_endpoints_advertise_a_versioned_example_base里补上("cloudflare-workers-ai", None)负例。
- 在
-
bareRootExample判断条件与写死的/v1文案存在耦合(顺手收紧)
products/maka/workbench/app/connectionEndpoint.ts里的bareRootExample只要 schema 的example带任意非空 path(apiPath(example))就会触发,但ConnectionForm.tsx里的提示文案写死了"Most OpenAI-compatible services expect a base URL ending in /v1, such as {example}."。后续如果有其他 provider 在 schema 里声明了非/v1的examples(例如/ai/v1或/v2),提示语会和示例自相矛盾。建议要么把判断收紧到apiPath(example) === '/v1',要么把提示文案改得不绑死OpenAI-compatible和/v1。
Cloudflare Workers AI needs a base ending in `/ai/v1`, so only providers with protocol model discovery advertise the generic example. The form note now appears only when the advertised example is a `/v1` base. Generated-by: Claude Code
|
@M4n5ter Thanks, both points are fixed. The example is now limited to providers with |
EnglishOne follow-up on the UI side: please drop the live bare-root
简体中文补充一条 UI 方面的意见:请直接去掉输入框下面这条实时
|
The live bare-root note appeared and disappeared while a URL was being typed, shifting the form layout, as raised in review. Drop the note, its helper and its locale entries; the versioned placeholder remains. Generated-by: Claude Code
|
@M4n5ter Done: the live note, |
M4n5ter
left a comment
There was a problem hiding this comment.
LGTM — clean schema-driven placeholder, cloudflare-workers-ai excluded, and no live layout shift.
Summary
Follow-up to #7527, as promised there.
Custom OpenAI-family providers (
openai-compatible,openai-responses-compatible,new-api,sub2api) now advertisehttps://api.example.com/v1as a JSON Schemaexamplesentry onbaseUrl. The example is derived from the runtime adapter and model discovery kind rather than provider IDs.The workbench connection form uses it as the Base URL placeholder. The value is never rewritten or blocked.
anthropic-compatible,cloudflare-workers-ai(which needs/ai/v1) and providers with a default base are unchanged. The iOS form is unchanged.Closes #3320
Verification
cargo test -p maka-providers: passed, including the newcustom_openai_endpoints_advertise_a_versioned_example_base. That test fails whenapi.rsis reverted tomain.cargo clippy -p maka-providers --all-targets -- -D warnings: passedcargo fmt -p maka-providers --check: passednode scripts/i18n/check.mjs: passednode --testonconnection-endpoint.test.mjs(new),connection-models.test.mjsandprovider-catalog.test.mjs: 8 passednpx biome checkon the changed TS/MJS files: passednode scripts/ci.mjs run contracts: one type error,products/maka/ios-shell/app/ui/HostListNotices.tsx(93,27)TS2339 (autoReconnect). This PR does not touch that file, and the same error occurs on the base commit 8c2b496.Not run: the desktop renderer suite. No screenshot is attached.
AI use
Select exactly one:
Tool(s) and scope: Claude Code, used to draft the change and tests; I reviewed the patch before submission.
Checklist
Does this PR entail a breaking change or persisted-data migration?
upgrade_compat.rscoverage under Summary aboveDoes this PR entail a change in behavior?