增加grok供应商类型
现在grok模型效果可以,sub2api、以及cpa都支持了,希望增加grok供应商类型;
Thank you for this feature suggestion. Below is a feasibility assessment based on the current codebase architecture.
Current state
Grok (xAI) is already recognized as a model vendor for display/icon purposes, but is not a dedicated provider type:
src/lib/model-vendor/vendor-inference.ts:143maps model names matching/grok/to thexaivendorsrc/lib/model-vendor/vendor-inference.ts:33-34and:318resolvexai/x-aito the display name "xAI"- Vendor icons exist in
src/lib/model-vendor-icons.tsx
The provider type enum (src/types/provider.ts:5-11) currently defines six types only:
"claude" | "claude-auth" | "codex" | "gemini" | "gemini-cli" | "openai-compatible"
Workaround available today
Because xAI's API (api.x.ai) is OpenAI Chat Completions compatible, Grok can already be used right now by configuring a provider with type openai-compatible:
src/app/v1/_lib/proxy/forwarder.ts:5043-5045setsAuthorization: Bearer <key>for bothcodexandopenai-compatibletypessrc/app/v1/_lib/models/available-models.ts:296mapsopenai-compatibleto the OpenAI upstream config
So you can add a provider pointing at the xAI endpoint with the openai-compatible type and route Grok models through it today.
What a dedicated grok provider type would require
If a first-class type is desired (e.g. for distinct auth, model discovery, or UI presets), the provider type is referenced in several places that would all need updating:
- Type definition:
src/types/provider.ts:5-11(the union) - Validation schemas:
src/lib/validation/schemas.ts:488-489and:737-738(two zod enums) - Proxy forwarder:
src/app/v1/_lib/proxy/forwarder.tshas multiple provider-type branches (auth header building at:5034-5045, request/body handling around:979,:2368,:2390,:5048) - Model routing:
src/app/v1/_lib/models/available-models.ts:293uses an exhaustiveRecord<Provider["providerType"], UpstreamFetchConfig>— TypeScript will fail to compile until agrokentry is added. ThegetProviderTypesForFormatswitch at:319-334also has aneverexhaustiveness check. - Provider selector:
src/app/v1/_lib/proxy/provider-selector.ts - UI forms:
src/app/[locale]/settings/providers/_components/forms/provider-form/sections/routing-section.tsx:79(the selectableproviderTypesarray) and the label switch at:55-68; alsomodel-multi-select.tsxandoptions-section.tsx - i18n strings: all 5 languages under
messages/{en,zh-CN,zh-TW,ja,ru}/settings/ - Tests: e.g.
tests/unit/api/v1/provider-types.test.ts
The exhaustiveness checks in available-models.ts are actually helpful here: they act as a compile-time checklist ensuring every new type is wired into routing and model discovery.
Automated response from Claude AI
hi,Grok 并不需要单独一个供应商类型。绝大多数上游(例如您说的 cpa/sub2api)有提供兼容接口,故本项目不计划单独增加。 未来我们会在重构版本中对更多 SDK 进行逐一适配,并提供集成转换器功能的网关,敬请期待。
hi,Grok 并不需要单独一个供应商类型。绝大多数上游(例如您说的 cpa/sub2api)有提供兼容接口,故本项目不计划单独增加。 未来我们会在重构版本中对更多 SDK 进行逐一适配,并提供集成转换器功能的网关,敬请期待。
感谢回复,不过我在测试sub2api的openai 兼容协议的时候,偶发还是会报错,感觉协议转换没有写好,所以想试试原生的接口;
This issue has been automatically marked as stale because it has not had any activity in the last 30 days.
If this issue is still relevant:
- Please comment to keep it open
- Add any new information that might help resolve it
This issue will be automatically closed in 14 days if there is no further activity.
This issue has been automatically marked as stale because it has not had any activity in the last 30 days.
If this issue is still relevant:
- Please comment to keep it open
- Add any new information that might help resolve it
This issue will be automatically closed in 14 days if there is no further activity.
This issue has been automatically closed due to inactivity.
If you believe this issue is still relevant, please feel free to reopen it with additional information.