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
/* Adapted from miuuyy/codex-chatgpt-web commit 09877fa21ffdbf20979623ef501046fc02a750d7 (MIT). */
export interface ChatGptWebAdapterErrorOptions {
status: number;
errorType: string;
code: string;
retryable: boolean;
}
export class ChatGptWebAdapterError extends Error {
readonly status: number;
readonly errorType: string;
readonly code: string;
readonly retryable: boolean;
constructor(message: string, options: ChatGptWebAdapterErrorOptions) {
super(message);
this.name = "ChatGptWebAdapterError";
this.status = options.status;
this.errorType = options.errorType;
this.code = options.code;
this.retryable = options.retryable;
}
}
export function chatGptBrowserTabClosedError(): ChatGptWebAdapterError {
return new ChatGptWebAdapterError(
"The ChatGPT browser tab was closed, so the Codex turn was cancelled.",
{
status: 499,
errorType: "client_closed_request",
code: "client_cancelled",
retryable: false,
}
);
}
export function chatGptStoppedThinkingError(): ChatGptWebAdapterError {
return new ChatGptWebAdapterError(
"ChatGPT remained in 'Stopped thinking' for 5 seconds, so the Codex turn was cancelled.",
{
status: 499,
errorType: "client_closed_request",
code: "client_cancelled",
retryable: false,
}
);
}
export function chatGptRetainedConversationUnavailableError(): ChatGptWebAdapterError {
return new ChatGptWebAdapterError("The retained ChatGPT conversation is no longer available.", {
status: 409,
errorType: "invalid_request_error",
code: "compaction_source_unavailable",
retryable: false,
});
}