Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors
TypeScript a2aai-agentsai-gatewayanthropicclaudeclaude-codeclinecodexcopilotcursordeepseekfree-aigeminikimillm-gatewaymcpopenaiopenai-proxyqwentoken-saver
/**
* Regression test ported from decolua/9router#1536 (follow-up to #663).
*
* GitHub Copilot's `/responses` endpoint only serves OpenAI (gpt/codex) models —
* Gemini and Claude models reject with HTTP 400
* "[github/<model>] [400]: model <model> does not support Responses API."
* (unsupported_api_for_model). They must therefore never be routed to
* `/responses`, no matter what `targetFormat` a registry entry (or any future
* misconfiguration) declares for them.
*
* OmniRoute's GithubExecutor decides the endpoint inside `buildUrl()` purely
* from `getModelTargetFormat("gh", model)`. The registry today (`open-sse/
* config/providers/registry/github/index.ts`) correctly omits
* `targetFormat: "openai-responses"` on every Claude/Gemini entry — but that is
* a single-line away from regressing (the file's own comments on lines 60, 74,
* 80 warn against it). This test pins the defensive invariant: even if a
* Claude/Gemini variant ends up tagged `openai-responses`, the executor must
* still build the chat/completions URL.
*/
import { describe, it } from "node:test";
import assert from "node:assert/strict";
import { GithubExecutor } from "../../open-sse/executors/github.ts";
import { PROVIDER_MODELS } from "../../open-sse/config/providerModels.ts";
import type { RegistryModel } from "../../open-sse/config/providerRegistry.ts";
const CHAT_URL = "https://api.githubcopilot.com/chat/completions";
const RESPONSES_URL = "https://api.githubcopilot.com/responses";
const MESSAGES_URL = "https://api.githubcopilot.com/v1/messages";
function getGithubModel(modelId: string): RegistryModel {
const model = PROVIDER_MODELS["gh"]?.find((entry) => entry.id === modelId);
assert.ok(model, `${modelId} must be registered`);
return model;
}
describe("GithubExecutor — Gemini/Claude must never hit /responses (port 9router#1536)", () => {
it("routes registered Claude Copilot models to the native /v1/messages shim (port decolua/9router#2608)", () => {
const exec = new GithubExecutor();
for (const id of [
"claude-haiku-4.5",
"claude-sonnet-5",
"claude-fable-5.1",
"claude-opus-5",
"claude-opus-4.8",
"claude-opus-4.8-fast",
]) {
assert.equal(exec.buildUrl(id, false), MESSAGES_URL, `${id} must route to /v1/messages`);
}
});
it("routes registered Gemini Copilot models to chat/completions", () => {
const exec = new GithubExecutor();
for (const id of ["gemini-3.8-flash"]) {
assert.equal(exec.buildUrl(id, false), CHAT_URL, `${id} must route to chat/completions`);
}
});
it("still avoids /responses if a Claude/Gemini model is wrongly tagged openai-responses", () => {
const exec = new GithubExecutor();
const claude = getGithubModel("claude-sonnet-5");
const gemini = getGithubModel("gemini-3.8-flash");
const originalClaude = claude.targetFormat;
const originalGemini = gemini.targetFormat;
try {
// Simulate a future misconfiguration. The guard must still hold: Claude
// ALWAYS resolves to the native /v1/messages shim (name match beats the
// bad tag), Gemini stays on /chat/completions. Neither hits /responses.
claude.targetFormat = "openai-responses";
gemini.targetFormat = "openai-responses";
assert.equal(exec.buildUrl("claude-sonnet-5", false), MESSAGES_URL);
assert.equal(exec.buildUrl("gemini-3.8-flash", false), CHAT_URL);
} finally {
claude.targetFormat = originalClaude;
gemini.targetFormat = originalGemini;
}
});
it("still routes registered OpenAI/codex Copilot models to /responses", () => {
const exec = new GithubExecutor();
for (const id of [
"gpt-6-astra",
"gpt-5.6-sol",
"gpt-5.6-terra",
"gpt-5.6-luna",
"mai-code-1.1-flash",
"grok-4.6",
]) {
assert.equal(exec.buildUrl(id, false), RESPONSES_URL, `${id} must route to /responses`);
}
});
it("is case-insensitive when guarding (defensive against upper/mixed-case ids)", () => {
const exec = new GithubExecutor();
const claude = getGithubModel("claude-sonnet-5");
const original = claude.targetFormat;
try {
claude.targetFormat = "openai-responses";
// Even wrongly tagged, a claude-* id resolves to the native shim (the
// name match is case-insensitive), never /responses.
assert.equal(exec.buildUrl("claude-sonnet-5", false), MESSAGES_URL);
} finally {
claude.targetFormat = original;
}
});
});