claude-code-hub icon indicating copy to clipboard operation
claude-code-hub copied to clipboard

增加grok供应商类型

Open 251392463 opened this issue 4 months ago • 6 comments

现在grok模型效果可以,sub2api、以及cpa都支持了,希望增加grok供应商类型;

Image

251392463 avatar Jul 15 '26 05:07 251392463

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:143 maps model names matching /grok/ to the xai vendor
  • src/lib/model-vendor/vendor-inference.ts:33-34 and :318 resolve xai/x-ai to 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-5045 sets Authorization: Bearer <key> for both codex and openai-compatible types
  • src/app/v1/_lib/models/available-models.ts:296 maps openai-compatible to 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-489 and :737-738 (two zod enums)
  • Proxy forwarder: src/app/v1/_lib/proxy/forwarder.ts has 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:293 uses an exhaustive Record<Provider["providerType"], UpstreamFetchConfig> — TypeScript will fail to compile until a grok entry is added. The getProviderTypesForFormat switch at :319-334 also has a never exhaustiveness 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 selectable providerTypes array) and the label switch at :55-68; also model-multi-select.tsx and options-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

github-actions[bot] avatar Jul 15 '26 05:07 github-actions[bot]

hi,Grok 并不需要单独一个供应商类型。绝大多数上游(例如您说的 cpa/sub2api)有提供兼容接口,故本项目不计划单独增加。 未来我们会在重构版本中对更多 SDK 进行逐一适配,并提供集成转换器功能的网关,敬请期待。

ding113 avatar Jul 16 '26 16:07 ding113

hi,Grok 并不需要单独一个供应商类型。绝大多数上游(例如您说的 cpa/sub2api)有提供兼容接口,故本项目不计划单独增加。 未来我们会在重构版本中对更多 SDK 进行逐一适配,并提供集成转换器功能的网关,敬请期待。

感谢回复,不过我在测试sub2api的openai 兼容协议的时候,偶发还是会报错,感觉协议转换没有写好,所以想试试原生的接口;

251392463 avatar Jul 17 '26 15:07 251392463

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.

github-actions[bot] avatar Aug 17 '26 00:08 github-actions[bot]

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.

github-actions[bot] avatar Aug 31 '26 01:08 github-actions[bot]

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.

github-actions[bot] avatar Sep 15 '26 02:09 github-actions[bot]