Skip to content

Use Claude Code with your ChatGPT, Kimi, Cursor or Grok subscription via a local Anthropic-compatible proxy

Rust

add model aliases for claude-style names

Raine Virtaac29a672755c
diff --git a/README.md b/README.md
index 0d8f16e..a413456 100644
--- a/README.md
+++ b/README.md
@@ -122,9 +122,27 @@ Also verified working on this project:
- `gpt-5.2`
- `gpt-5.4-mini`
-If you pass a model your account isn't entitled to, upstream returns a 400 like
-`"The 'gpt-4.1' model is not supported when using Codex with a ChatGPT account."`.
-The proxy surfaces that verbatim.
+The proxy also accepts a small set of convenience aliases and resolves them
+before calling the upstream Codex backend:
+
+- `haiku`, `claude-haiku-4-5`, `claude-haiku-4-5-20251001` → `gpt-5.4-mini`
+- `sonnet`, `claude-sonnet-4-6` → `gpt-5.4`
+- `opus`, `claude-opus-4-7` → `gpt-5.4`
+
+These aliases are only shorthand for portability and cheaper subagent configs;
+they are not semantic equivalents of the Claude models they resemble.
+
+If the resolved model isn't supported by your account, upstream returns a 400
+like `"The 'gpt-4.1' model is not supported when using Codex with a ChatGPT
+account."`. The proxy surfaces that verbatim.
+
+For example, you can now point Claude Code or a subagent at the proxy with:
+
+```sh
+ANTHROPIC_MODEL=haiku claude
+```
+
+and the proxy will send `gpt-5.4-mini` upstream.
## How it works
diff --git a/src/server.ts b/src/server.ts
index 2f1d73e..eb7c87f 100644
--- a/src/server.ts
+++ b/src/server.ts
@@ -1,6 +1,6 @@
import { createLogger, logDir } from "./log.ts"
import type { AnthropicRequest } from "./anthropic/schema.ts"
-import { assertAllowedModel, ModelNotAllowedError } from "./translate/model-allowlist.ts"
+import { assertAllowedModel, ModelNotAllowedError, resolveModel } from "./translate/model-allowlist.ts"
import { translateRequest } from "./translate/request.ts"
import { translateStream } from "./translate/stream.ts"
import { accumulateResponse, UpstreamStreamError } from "./translate/accumulate.ts"
@@ -87,22 +87,26 @@ async function handleMessages(req: Request, reqId: string): Promise<Response> {
})
if (VERBOSE) log.debug("anthropic request body", { reqId, body })
+ const resolvedModel = resolveModel(body.model)
+
try {
- assertAllowedModel(body.model)
+ assertAllowedModel(resolvedModel)
} catch (err) {
if (err instanceof ModelNotAllowedError) {
return jsonError(
400,
"invalid_request_error",
- `Model "${err.model}" is not in the Codex OAuth allowlist`,
+ `Model "${body.model}" resolves to unsupported model "${err.model}"`,
)
}
throw err
}
- const translated = translateRequest(body, { sessionId })
+ const translated = translateRequest({ ...body, model: resolvedModel }, { sessionId })
log.debug("translated request", {
reqId,
+ requestedModel: body.model,
+ resolvedModel,
inputItems: translated.input.length,
tools: translated.tools?.length ?? 0,
hasInstructions: !!translated.instructions,
diff --git a/src/translate/model-allowlist.ts b/src/translate/model-allowlist.ts
index c561967..5ff3744 100644
--- a/src/translate/model-allowlist.ts
+++ b/src/translate/model-allowlist.ts
@@ -5,6 +5,20 @@ export const ALLOWED_MODELS = new Set([
"gpt-5.4-mini",
])
+export const MODEL_ALIASES = new Map<string, string>([
+ ["haiku", "gpt-5.4-mini"],
+ ["claude-haiku-4-5", "gpt-5.4-mini"],
+ ["claude-haiku-4-5-20251001", "gpt-5.4-mini"],
+ ["sonnet", "gpt-5.4"],
+ ["claude-sonnet-4-6", "gpt-5.4"],
+ ["opus", "gpt-5.4"],
+ ["claude-opus-4-7", "gpt-5.4"],
+])
+
+export function resolveModel(model: string): string {
+ return MODEL_ALIASES.get(model) ?? model
+}
+
export function assertAllowedModel(model: string): void {
if (!ALLOWED_MODELS.has(model)) {
throw new ModelNotAllowedError(model)