mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-24 12:44:18 +08:00
feat(codex): add xAI (Grok) native Responses preset
API-key preset pointing at https://api.x.ai/v1 with wire_api = "responses": xAI serves the Responses API natively, so no route takeover conversion is needed. Ships a grok-4.5 catalog entry (500K context, parallel tools, text+image) so the model shows up under Codex's strict catalog parsing. This is deliberately not a managed-account preset: providerType stays absent, pinned by a regression test alongside the Claude-side xAI OAuth presets.
This commit is contained in:
@@ -999,6 +999,30 @@ requires_openai_auth = true`,
|
||||
icon: "novita",
|
||||
iconColor: "#000000",
|
||||
},
|
||||
{
|
||||
name: "xAI (Grok)",
|
||||
websiteUrl: "https://x.ai/api",
|
||||
apiKeyUrl: "https://console.x.ai",
|
||||
auth: generateThirdPartyAuth(""),
|
||||
config: generateThirdPartyConfig("xai", "https://api.x.ai/v1", "grok-4.5"),
|
||||
endpointCandidates: ["https://api.x.ai/v1"],
|
||||
// xAI 官方以 /v1/responses 为一等端点(docs.x.ai api-reference):Codex 硬依赖的
|
||||
// store:false / include=["reasoning.encrypted_content"] / reasoning effort 均支持,
|
||||
// 原生 Responses,无需路由接管转换
|
||||
apiFormat: "openai_responses",
|
||||
modelCatalog: modelCatalog([
|
||||
{
|
||||
model: "grok-4.5",
|
||||
displayName: "Grok 4.5",
|
||||
contextWindow: 500000,
|
||||
supportsParallelToolCalls: true,
|
||||
inputModalities: ["text", "image"],
|
||||
},
|
||||
]),
|
||||
category: "third_party",
|
||||
icon: "xai",
|
||||
iconColor: "#000000",
|
||||
},
|
||||
{
|
||||
name: "Nvidia",
|
||||
websiteUrl: "https://build.nvidia.com",
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { claudeDesktopProviderPresets } from "@/config/claudeDesktopProviderPresets";
|
||||
import { providerPresets } from "@/config/claudeProviderPresets";
|
||||
import { codexProviderPresets } from "@/config/codexProviderPresets";
|
||||
import {
|
||||
extractCodexBaseUrl,
|
||||
extractCodexModelName,
|
||||
extractCodexWireApi,
|
||||
} from "@/utils/providerConfigUtils";
|
||||
|
||||
describe("xAI OAuth provider presets", () => {
|
||||
it("pins the Claude Code preset to managed Responses auth", () => {
|
||||
@@ -48,4 +54,30 @@ describe("xAI OAuth provider presets", () => {
|
||||
}),
|
||||
]);
|
||||
});
|
||||
|
||||
it("pins the Codex preset to native Responses via API key (no managed OAuth)", () => {
|
||||
const preset = codexProviderPresets.find(
|
||||
(entry) => entry.name === "xAI (Grok)",
|
||||
);
|
||||
expect(preset).toBeDefined();
|
||||
expect(preset).toMatchObject({
|
||||
category: "third_party",
|
||||
apiFormat: "openai_responses",
|
||||
icon: "xai",
|
||||
});
|
||||
// API-key preset: managed-account OAuth is Claude-side only for now.
|
||||
expect(preset).not.toHaveProperty("providerType");
|
||||
expect(preset!.auth).toEqual({ OPENAI_API_KEY: "" });
|
||||
expect(extractCodexBaseUrl(preset!.config)).toBe("https://api.x.ai/v1");
|
||||
expect(extractCodexWireApi(preset!.config)).toBe("responses");
|
||||
expect(extractCodexModelName(preset!.config)).toBe("grok-4.5");
|
||||
expect(preset!.modelCatalog).toEqual([
|
||||
expect.objectContaining({
|
||||
model: "grok-4.5",
|
||||
contextWindow: 500000,
|
||||
supportsParallelToolCalls: true,
|
||||
inputModalities: ["text", "image"],
|
||||
}),
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user