Use Claude Code with your ChatGPT, Kimi, Cursor or Grok subscription via a local Anthropic-compatible proxy
Rust
add model and effort override env vars
Omar Abdulla4d552f1d4b17
diff --git a/src/anthropic/schema.ts b/src/anthropic/schema.tsindex bda93bf..916a628 100644--- a/src/anthropic/schema.ts+++ b/src/anthropic/schema.ts@@ -61,7 +61,7 @@ export interface AnthropicRequest {stream?: booleanthinking?: { type: string; [k: string]: unknown }output_config?: {- effort?: "low" | "medium" | "high"+ effort?: "low" | "medium" | "high" | "xhigh"format?: { type: "json_schema"; schema: unknown; name?: string; strict?: boolean }}context_management?: unknowndiff --git a/src/providers/codex/translate/model-allowlist.ts b/src/providers/codex/translate/model-allowlist.tsindex 5ff3744..580d57e 100644--- a/src/providers/codex/translate/model-allowlist.ts+++ b/src/providers/codex/translate/model-allowlist.ts@@ -16,6 +16,20 @@ export const MODEL_ALIASES = new Map<string, string>([])export function resolveModel(model: string): string {+ // The CLAUDE_CODEX_PROXY_OPEN_AI_MODEL_OVERRIDE environment variable allows+ // for the model that's used to be overridden so that regardless of whatever+ // model is being requested by the harness, the model which is provided in+ // that env var is always returned.+ //+ // This is useful in cases where you just want the claude-code harness to use+ // a specific model all across the way.+ if (+ process.env.CLAUDE_CODEX_PROXY_OPEN_AI_MODEL_OVERRIDE !== undefined &&+ process.env.CLAUDE_CODEX_PROXY_OPEN_AI_MODEL_OVERRIDE !== ""+ ) {+ return process.env.CLAUDE_CODEX_PROXY_OPEN_AI_MODEL_OVERRIDE+ }+return MODEL_ALIASES.get(model) ?? model}diff --git a/src/providers/codex/translate/request.ts b/src/providers/codex/translate/request.tsindex ac0f115..6899243 100644--- a/src/providers/codex/translate/request.ts+++ b/src/providers/codex/translate/request.ts@@ -7,6 +7,8 @@ import type {AnthropicTool,} from "../../../anthropic/schema.ts"+export type Effort = "none" | "low" | "medium" | "high" | "xhigh"+// Keep this aligned to the upstream Codex ResponsesApiRequest field set.// Do not add plausible-looking top-level fields without source support or a confirmed live test.export interface ResponsesRequest {@@ -20,7 +22,7 @@ export interface ResponsesRequest {| "required"| { type: "function"; name: string }parallel_tool_calls?: boolean- reasoning?: { effort?: "low" | "medium" | "high"; summary?: unknown }+ reasoning?: { effort?: Effort; summary?: unknown }store: falsestream: trueinclude?: string[]@@ -71,6 +73,24 @@ export interface TranslateOptions {sessionId?: string}+function resolveEffort(effort?: Effort): Effort | undefined {+ // The CLAUDE_CODEX_PROXY_OPEN_AI_EFFORT_OVERRIDE environment variable allows+ // for the effort that's used to be overridden so that regardless of whatever+ // effort is being requested by the harness, the effort which is provided in+ // that env var is always returned.+ //+ // This is useful in cases where you just want the claude-code harness to use+ // a specific effort all across the way.+ if (+ process.env.CLAUDE_CODEX_PROXY_OPEN_AI_EFFORT_OVERRIDE !== undefined &&+ process.env.CLAUDE_CODEX_PROXY_OPEN_AI_EFFORT_OVERRIDE !== ""+ ) {+ return process.env.CLAUDE_CODEX_PROXY_OPEN_AI_EFFORT_OVERRIDE as Effort+ }++ return effort+}+export function translateRequest(req: AnthropicRequest, opts: TranslateOptions = {}): ResponsesRequest {const instructions = buildInstructions(req.system)const input = buildInput(req.messages)@@ -99,7 +119,7 @@ export function translateRequest(req: AnthropicRequest, opts: TranslateOptions =if (instructions) out.instructions = instructionsif (tools && tools.length) out.tools = toolsif (opts.sessionId) out.prompt_cache_key = opts.sessionId- const effort = req.output_config?.effort+ const effort = resolveEffort(req.output_config?.effort)if (effort) {out.reasoning = { effort }out.include = ["reasoning.encrypted_content"]diff --git a/src/providers/kimi/translate/request.ts b/src/providers/kimi/translate/request.tsindex b74d694..5535436 100644--- a/src/providers/kimi/translate/request.ts+++ b/src/providers/kimi/translate/request.ts@@ -86,7 +86,7 @@ export function translateRequest(stream: true,stream_options: { include_usage: true },max_tokens: clampMaxTokens(req.max_tokens),- reasoning_effort: req.output_config?.effort ?? "medium",+ reasoning_effort: mapReasoningEffort(req.output_config?.effort),thinking: { type: "enabled" },}if (tools && tools.length) out.tools = tools@@ -101,6 +101,16 @@ function clampMaxTokens(requested: number | undefined): number {return Math.min(requested, DEFAULT_MAX_TOKENS)}+// Kimi's reasoning_effort is capped at "high"; collapse the proxy's "xhigh"+// extension to "high" since Kimi has no stronger tier, and default to "medium"+// when no effort is requested.+function mapReasoningEffort(+ effort: NonNullable<AnthropicRequest["output_config"]>["effort"],+): "low" | "medium" | "high" {+ if (effort === "xhigh") return "high"+ return effort ?? "medium"+}+function mapToolChoice(choice: AnthropicRequest["tool_choice"]): KimiToolChoice {if (!choice) return "auto"switch (choice.type) {