mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-24 12:44:18 +08:00
feat(xai): add Grok OAuth presets for Claude and Claude Desktop
Register the xai_oauth provider type constant and add xAI (Grok) presets targeting grok-4.5. The Desktop preset routes branded claude-* model IDs to grok-4.5 upstream so it passes Desktop's third-party model validation.
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { claudeDesktopProviderPresets } from "@/config/claudeDesktopProviderPresets";
|
||||
import { providerPresets } from "@/config/claudeProviderPresets";
|
||||
|
||||
describe("xAI OAuth provider presets", () => {
|
||||
it("pins the Claude Code preset to managed Responses auth", () => {
|
||||
const preset = providerPresets.find((entry) => entry.name === "xAI (Grok)");
|
||||
expect(preset).toBeDefined();
|
||||
expect(preset).toMatchObject({
|
||||
category: "third_party",
|
||||
apiFormat: "openai_responses",
|
||||
providerType: "xai_oauth",
|
||||
requiresOAuth: true,
|
||||
icon: "xai",
|
||||
});
|
||||
expect((preset!.settingsConfig as any).env).toMatchObject({
|
||||
ANTHROPIC_BASE_URL: "https://api.x.ai/v1",
|
||||
ANTHROPIC_MODEL: "grok-4.5",
|
||||
ANTHROPIC_DEFAULT_HAIKU_MODEL: "grok-4.5",
|
||||
ANTHROPIC_DEFAULT_SONNET_MODEL: "grok-4.5",
|
||||
ANTHROPIC_DEFAULT_OPUS_MODEL: "grok-4.5",
|
||||
});
|
||||
expect((preset!.settingsConfig as any).env).not.toHaveProperty(
|
||||
"ANTHROPIC_API_KEY",
|
||||
);
|
||||
expect((preset!.settingsConfig as any).env).not.toHaveProperty(
|
||||
"ANTHROPIC_AUTH_TOKEN",
|
||||
);
|
||||
});
|
||||
|
||||
it("pins the Claude Desktop preset to proxy Responses mode without 1M", () => {
|
||||
const preset = claudeDesktopProviderPresets.find(
|
||||
(entry) => entry.name === "xAI (Grok)",
|
||||
);
|
||||
expect(preset).toMatchObject({
|
||||
category: "third_party",
|
||||
baseUrl: "https://api.x.ai/v1",
|
||||
mode: "proxy",
|
||||
apiFormat: "openai_responses",
|
||||
providerType: "xai_oauth",
|
||||
requiresOAuth: true,
|
||||
icon: "xai",
|
||||
});
|
||||
expect(preset!.modelRoutes).toEqual([
|
||||
expect.objectContaining({
|
||||
upstreamModel: "grok-4.5",
|
||||
supports1m: false,
|
||||
}),
|
||||
]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user