Skip to content
Projects

About

Kiro代理到Claude Code与Codex,支持Claude Fable5.2/5.1 Opus5.5/5/4.8/4.7/4.6、Sonnet5.5/5/4.6、Haiku5.5、GPT-5.6、Kimi K3、Grok-4.7,支持前缀缓存,并支持SSE流式输出。Kiro proxy for Claude Code and Codex. Supports Claude Opus5.5/5/4.8/4.7/4.6, Sonnet 5.5/5/4.6, Haiku5.5,GPT-5.6, Kimi K3,Grok-4.7, Supports Prefix Cache, and SSE streaming.

Developer Tools

How these counts are measured

Measured star growth

in 24h
0
in 7 days
+3
in 15 days
+12
in 1 month
Collecting history

Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.

README.en.md

Original

🌉 kiro2cc-proxy

A Rust-based Anthropic Claude API-compatible proxy that converts Anthropic API requests into Kiro API requests.

Tests codecov License: MIT

🇺🇸 English | 🇨🇳 中文

Admin Panel

✅ Supported Models: Claude Sonnet 5.5 / Claude Sonnet 5 / Claude Sonnet 4.5 / Claude Sonnet 4.6 / Claude Opus 5.5 / Claude Opus 5 / Claude Opus 4.5 / Claude Opus 4.6 / Claude Opus 4.7 / Claude Opus 4.8 / Claude Haiku 5.5 / Claude Haiku 4.5 / Claude Fable 5.2 / Claude Fable 5.1 / DeepSeek 3.2 / GLM-5 / MiniMax M2.1 / MiniMax M2.5 / Qwen3-Coder-Next / Kimi K3 / Grok 4.7 / Amazon Ergo / GPT-5.6 Sol / GPT-5.6 Terra / GPT-5.6 Luna / GPT 6.2 Astra / GPT 6 Luna

📖 Quick Navigation

🚀 Quick Start ・ 📦 Prebuilt Package Deployment ・ 🍎 macOS Deployment ・ 🪟 Windows Deployment ・ 🐧 Linux Deployment ・ 🔑 Get Accounts ・ ⚙️ Configuration ・ 🤖 Claude Code Integration ・ 🧬 Codex CLI / OpenAI SDK ・ 🔌 API Endpoints ・ 🗺️ Model Mapping ・ 🛡️ Admin Panel ・ ❓ FAQ ・ ⚠️ Notes


⚠️ Disclaimer

This project is for research purposes only. Use at your own risk. Any consequences arising from the use of this project are solely the responsibility of the user. This project is not affiliated with AWS, KIRO, Anthropic, or Claude in any official capacity.


✨ Features

Feature Description
🔌 Anthropic API Compatible Full support for the Anthropic Claude API format
🧬 OpenAI Compatible / Codex CLI Exposes /v1/chat/completions and /v1/responses endpoints for direct Codex CLI and OpenAI SDK client integration
📡 Streaming Responses SSE (Server-Sent Events) streaming support
🔍 WebSearch Built-in WebSearch tool conversion logic, i.e. supports web search in Claude Code
🔄 Auto Token Refresh Automatically manages and refreshes OAuth tokens
👥 Multi-Account Support Configure multiple accounts with automatic priority-based failover
⚖️ Load Balancing priority (by priority) and balanced (round-robin) modes
🔁 Smart Retry Up to 3 retries per account, up to 9 retries per request
🧠 Thinking Mode Supports Claude's extended thinking feature
🛠️ Tool Use Full support for function calling / tool use
🛡️ Admin Panel Optional web management UI for account management, balance queries, etc.
🌐 Per-Account Proxy Configure HTTP/SOCKS5 proxy per account

🚀 Quick Start (New Users)

What is this project?

kiro2cc-proxy is a proxy service. It forwards standard Anthropic Claude API requests to Kiro (AWS's AI coding tool), allowing you to use Claude Code with models from your Kiro account.

In short: it proxies the models on your logged-in Kiro account to Claude Code. Without it, you can only use those models inside Kiro IDE or Kiro CLI.

Prerequisites:

  1. A Kiro account (register at kiro.dev, supports Social login)
  2. Accounts exported from Kiro IDE or account manager (refreshToken etc.)
  3. ⚠️ [CRITICAL] Users in mainland China: A local HTTP/SOCKS5 proxy (Clash/V2Ray etc.) is mandatory. Without it, all Claude model requests will return INVALID_MODEL_ID and the service will be unusable.

Overall flow:

Install dependencies → Build project → Start service → Add accounts → Configure client

💡 No Node.js / Rust toolchain? Download the prebuilt package and skip the first two steps.


📦 Prebuilt Package Deployment

For macOS (Apple Silicon / Intel) and Windows x64. If you don't want to install the Node.js and Rust toolchains, download the archive for your platform from Releases.

⚠️ Each archive contains only the kiro2cc-proxy executable: the repository launch scripts (run-local-service-mac.sh / run-local-service-windows.ps1) and their setup wizard are not included, so create the config files manually as described below.

Step 1: Download the Archive for Your Platform

Platform File
macOS Apple Silicon (M series) kiro2cc-proxy-vX.Y.Z-macOS-arm64.tar.gz
macOS Intel kiro2cc-proxy-vX.Y.Z-macOS-x64.tar.gz
Windows x64 kiro2cc-proxy-vX.Y.Z-Windows-x64.zip

Run uname -m if unsure: arm64 → Apple Silicon build, x86_64 → Intel build.

Verify integrity (optional): download checksums-sha256.txt from the same page, then

# macOS / Linux (macOS ships shasum, not sha256sum)
shasum -a 256 -c checksums-sha256.txt
# Windows PowerShell
Get-FileHash .\kiro2cc-proxy-vX.Y.Z-Windows-x64.zip -Algorithm SHA256

Step 2: Extract and Make Executable

# macOS
mkdir -p ~/kiro2cc && cd ~/kiro2cc
tar -xzf ~/Downloads/kiro2cc-proxy-vX.Y.Z-macOS-arm64.tar.gz
chmod +x kiro2cc-proxy
xattr -d com.apple.quarantine kiro2cc-proxy 2>/dev/null   # unsigned binary: remove the quarantine flag or Gatekeeper may block it

Windows: extract the zip, then double-click kiro2cc-proxy.exe or run .\kiro2cc-proxy.exe in PowerShell.

Step 3: Create config.json

The prebuilt package does not generate config files on startup. Without config.json the binary starts with built-in defaults: it listens on 127.0.0.1:8080 with an empty adminPsw, and /admin, /api/admin and /api/user are not mounted at all — opening the admin panel returns 404. Create the config first:

cat > config.json <<'EOF'
{
  "port": 8080,
  "adminPsw": "replace-with-your-admin-password",
  "proxyUrl": "http://127.0.0.1:7890"
}
EOF
  • proxyUrl is your local proxy port (Clash / V2Ray, the port you use for tunneling). Users in mainland China cannot reach Claude models without it.
  • Config files and runtime state are read/written in the current working directory; to start from another directory, pass --config <path> --credentials <path>.
  • Environment variables can override instead (PORT, ADMIN_PSW, PROXY_URL, etc.) — see Configuration Reference.

Step 4: Add Kiro Accounts

  • Option 1: start the service, open http://127.0.0.1:8080/admin, and use "KAM Import" to paste or drop the JSON exported by KAM.
  • Option 2: create credentials.json directly — see credentials.json Format.

Step 5: Start and Connect Your Client

./kiro2cc-proxy           # macOS
.\kiro2cc-proxy.exe       # Windows PowerShell

Runs in the foreground; stop with Ctrl+C. For client setup see Claude Code Integration and Codex CLI / OpenAI SDK.

Differences vs. the Repository Scripts

Item Repository scripts Prebuilt package
Setup wizard Yes, interactive on first start No, write config.json by hand
Config location app/config/ inside the repo Current working directory
Default port 5678 8080
Prerequisites Node.js + Rust (frontend and binary must be built first) None, only the executable

🍎 Local Deployment (macOS)

Step 1: Install Dependencies

Open Terminal and install Node.js and Rust:

# Install Homebrew (skip if already installed)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Install Node.js
brew install node

# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# After installation, reopen Terminal or run:
source "$HOME/.cargo/env"

Step 2: Get the Code

git clone https://github.com/TsinHzl/kiro2cc-proxy.git
cd kiro2cc-proxy

(Optional) Install Shell Aliases

Run the one-click installer to make build_kiro2cc_proxy, build_and_run_kiro2cc_proxy and run_kiro2cc_proxy available from any terminal — no need to navigate to the project directory each time:

bash setup_shell_aliases.sh
source ~/.zshrc   # zsh users; bash users run: source ~/.bashrc

After installation:

build_kiro2cc_proxy         # equivalent to ./build-mac.sh
build_and_run_kiro2cc_proxy # equivalent to ./build-and-run-mac.sh (build, then run)
run_kiro2cc_proxy           # equivalent to ./run-local-service-mac.sh

macOS only. Modifies ~/.zshrc and ~/.bashrc (if they exist). Safe to run multiple times (idempotent).

Step 3: Build the Project

./build-mac.sh

This script builds the web-ui/admin-ui frontend, web-ui/user-ui frontend, and then compiles the Rust binary. First build takes 5–15 minutes.

On success:

  Build complete!
  Binary: ./target/release/kiro2cc-proxy

No need to rebuild unless you update the code.

Step 4: Start the Service

Option A: Double-click (recommended)

In Finder, navigate to the project directory and double-click run-local-service-mac.sh.

Option B: Terminal

./run-local-service-mac.sh

First launch shows a setup wizard:

Admin Password (admin panel password (http://ip:port/admin), press Enter to skip): [default: my-admin-pass]
Port [default: 5678]:
Region [default: us-east-1]:
Local HTTP proxy port (e.g. 7890 / 10089): [enter your proxy port]
  • ⚠️ [CRITICAL] Local HTTP proxy port: This is the port your VPN/proxy software listens on. Without it, Claude models such as Claude 4.6 and Claude 4.7 will be inaccessible when running locally.

  • ⚠️ [CRITICAL] Proxy port (required for mainland China users)

    A common way to check: run export http_proxy=http://127.0.0.1:10089; export https_proxy=http://127.0.0.1:10089; in your terminal — the 10089 here is your proxy port.

    If you don't know the port number, check the settings page of your proxy software.

  • Admin Password: The login password for the admin panel (http://ip:port/admin). Setting this is recommended.

After setup, app/config/config.json is generated, the service starts, and the admin panel opens in your browser automatically.

Subsequent launches read the existing config — no wizard needed.

Step 5: Add Kiro Accounts

After the service starts, open the admin panel at http://127.0.0.1:5678/admin and click KAM Account Import on the accounts management page. This entry supports both single-account and multi-account KAM export JSON. Paste JSON text or drag in a .json file. After you click Import, accounts are created disabled and quota verification runs automatically; successfully verified accounts are enabled, while accounts that fail verification remain retained and disabled.

Alternatively, create app/config/credentials.json directly — see the "Getting Kiro Accounts" section.

Stop the Service

Press Ctrl+C in the terminal running the service, or close the terminal window.


🪟 Local Deployment (Windows)

Step 1: Install Dependencies

  1. Install Node.js (LTS version)
  2. Install Rust (download and run rustup-init.exe)
  3. Install Git

After installation, reopen PowerShell and verify these commands work:

node -v
cargo -v
git -v

Step 2: Get the Code

git clone https://github.com/TsinHzl/kiro2cc-proxy.git
cd kiro2cc-proxy

(Optional) Install PowerShell Aliases

Run the one-click installer to make build_kiro2cc_proxy, build_and_run_kiro2cc_proxy and run_kiro2cc_proxy available from any PowerShell window — no need to navigate to the project directory each time:

.\setup_shell_aliases.ps1
. $PROFILE

After installation:

build_kiro2cc_proxy         # equivalent to .\build-windows.ps1
build_and_run_kiro2cc_proxy # equivalent to .\build-and-run-windows.ps1 (build, then run)
run_kiro2cc_proxy           # equivalent to .\run-local-service-windows.ps1

Updates both Windows PowerShell 5.x and PowerShell 7+ profiles. Safe to run multiple times (idempotent).

Step 3: Build the Project

Open PowerShell as Administrator and allow script execution (one-time):

Set-ExecutionPolicy -Scope CurrentUser RemoteSigned

Then build:

.\build-windows.ps1

This script builds the web-ui/admin-ui frontend, web-ui/user-ui frontend, and then compiles the Rust binary. First build takes 5–15 minutes.

No need to rebuild unless you update the code.

Step 4: Start the Service

.\run-local-service-windows.ps1

First launch shows a setup wizard:

Admin Password (admin panel password (http://ip:port/admin), press Enter to skip): [default: my-admin-pass]
Port [default: 5678]:
Region [default: us-east-1]:
Local HTTP proxy port (e.g. 7890 / 10089): [enter your proxy port]
  • ⚠️ [CRITICAL] Local HTTP proxy port: This is the port your VPN/proxy software listens on. Without it, Claude models such as Claude 4.6 and Claude 4.7 will be inaccessible when running locally.

  • ⚠️ [CRITICAL] Proxy port (required for mainland China users)

    A common way to check: run export http_proxy=http://127.0.0.1:10089; export https_proxy=http://127.0.0.1:10089; in your terminal — the 10089 here is your proxy port.

    If you don't know the port number, check the settings page of your proxy software.

  • Admin Password: The login password for the admin panel (http://ip:port/admin). Setting this is recommended.

After setup, app\config\config.json is generated, the service starts, and the admin panel opens in your browser automatically.

Subsequent launches read the existing config — no wizard needed.

Step 5: Add Kiro Accounts

After the service starts, open the admin panel at http://127.0.0.1:5678/admin and click KAM Account Import on the accounts management page. This entry supports both single-account and multi-account KAM export JSON. Paste JSON text or drag in a .json file. After you click Import, accounts are created disabled and quota verification runs automatically; successfully verified accounts are enabled, while accounts that fail verification remain retained and disabled.

Stop the Service

Press Ctrl+C in the PowerShell window, or close the window.


🐧 Server Deployment (Linux)

Option 1: Docker Compose + GHCR Prebuilt Image (Recommended)

Deploy directly with the prebuilt ghcr.io/tsinhzl/kiro2cc-proxy image. No repository clone, Rust / Node.js installation, or local compilation is required. Images support linux/amd64 and linux/arm64; Docker automatically selects the matching architecture.

Requirements: Docker and Docker Compose (supporting the docker compose command) installed on the server, with network access to ghcr.io.

1. Create the Deployment Directory

mkdir -p /opt/kiro2cc-proxy/data
cd /opt/kiro2cc-proxy

2. Create the Compose File

Run the following commands to create docker-compose.yml in the deployment directory with the default configuration. This overwrites any existing file with the same name; for an existing deployment, back up and preserve your custom configuration instead of running these commands directly.

cd /opt/kiro2cc-proxy
cat > docker-compose.yml <<'EOF'
services:
  kiro2cc-proxy:
    image: ghcr.io/tsinhzl/kiro2cc-proxy:latest
    container_name: kiro2cc-proxy
    extra_hosts:
      - "host.docker.internal:host-gateway"
    ports:
      - "0.0.0.0:5678:5678"
    volumes:
      - ./data:/app/config
    restart: unless-stopped
EOF

Available image tags:

Tag Purpose
latest Image from the most recent release build, for following release updates
vX.Y.Z A published version tag; pin an existing version in production to control upgrades
beta Rolling test image from regular main-branch builds; not recommended for production

3. Create the Configuration File

Replace your-admin-password below with your own strong password before running these commands to create data/config.json with the minimal configuration. This overwrites any existing file with the same name; for an existing deployment, preserve the original file instead of running these commands directly.

cd /opt/kiro2cc-proxy
mkdir -p data
cat > data/config.json <<'EOF'
{
  "host": "0.0.0.0",
  "port": 5678,
  "region": "us-east-1",
  "adminPsw": "your-admin-password"
}
EOF

⚠️ port must be an integer, not a Docker port-mapping string (e.g. "0.0.0.0:5678:5678"). Correct: "port": 5678. The service will fail to start if this is wrong.

Keep the container's host set to 0.0.0.0 so the service is reachable through Docker's port mapping. The configuration file belongs in the host's data/ directory, not data/config/.

If data/credentials.json is missing, it is created automatically at startup. You can then add accounts through the admin panel, or place an existing credentials file there before starting. Do not overwrite an existing credentials file with an empty array.

4. Pull the Image and Start

cd /opt/kiro2cc-proxy
docker compose pull
docker compose up -d

# View logs
docker compose logs -f

# Stop
docker compose down

Open http://your-server-ip:5678/admin, sign in with adminPsw, add Kiro accounts, and create an API Key for your clients.

Network access: The mapping above listens on all host IPv4 interfaces. For remote access, allow TCP port 5678 through the firewall and cloud security group as needed, preferably restricting source IPs. Use an HTTPS reverse proxy for public access. For host-only access, change ports to "127.0.0.1:5678:5678" while keeping the container's host set to 0.0.0.0.

Data persistence: ./data:/app/config stores configuration, accounts, API Keys, usage records, and other data. Keep the original deployment directory and mount when upgrading or recreating the container, and ensure the directory remains writable. Do not delete or publicly share data/.

Updating to the Latest Version

Back up the entire data/ directory before upgrading. When using the latest tag, run:

cd /opt/kiro2cc-proxy
docker compose pull
docker compose up -d

The pull command only downloads the image. The subsequent up -d recreates the container if the image has changed, preserving mounted data. Neither git pull nor a preceding docker compose down is required. For a pinned version, first change the image tag to the desired published version, then run the commands above.

Option 2: Repository Clone + Docker Compose

The original repository-clone workflow remains available for users who prefer to reuse the repository's configuration files. It also pulls ghcr.io/tsinhzl/kiro2cc-proxy:latest by default, without building the image locally. Prefer the recommended option above if you do not need the repository files.

Requirements: Git, Docker, and Docker Compose installed, with access to GitHub and ghcr.io.

1. Clone the Repository

These commands are for a new deployment; the target directory should not already exist. For an existing clone, enter its original directory instead. Choose one Docker deployment method rather than mixing initialization steps in the same directory.

git clone https://github.com/TsinHzl/kiro2cc-proxy.git /opt/kiro2cc-proxy
cd /opt/kiro2cc-proxy

2. Create the Configuration File

mkdir -p data
if [ ! -f data/config.json ]; then
  cp config.example.json data/config.json
fi
nano data/config.json

Change host from the example's 127.0.0.1 to 0.0.0.0, set adminPsw to your own strong password, and keep the integer port "port": 5678. The minimal configuration is the same as in the recommended option above. The file belongs at data/config.json, not data/config/config.json.

The container automatically creates data/credentials.json if it is missing. Add accounts through the admin panel after startup; preserve any existing credentials file instead of overwriting it with an empty array.

3. Start and Manage the Service

docker compose pull
docker compose up -d

# View logs
docker compose logs -f

# Stop
docker compose down

Open http://your-server-ip:5678/admin and sign in with adminPsw. The port access restrictions, HTTPS guidance, and data/ persistence requirements from the recommended option also apply here.

Updating the Repository and Image

Back up the entire data/ directory before upgrading. If you have modified repository files, review and handle those local changes before updating the repository:

cd /opt/kiro2cc-proxy
git pull
docker compose pull
docker compose up -d

Skip git pull if you only need to update the image. The repository's Compose file defaults to latest. If you override IMAGE_OWNER / IMAGE_TAG through environment variables or .env, check the actual image source and tag first. For a pinned version, change IMAGE_TAG to the desired published version before pulling and recreating the container.

Option 3: systemd One-Click Install

For running the binary directly without Docker.

# 1. Clone the repo
git clone https://github.com/TsinHzl/kiro2cc-proxy.git /opt/kiro2cc-proxy-src
cd /opt/kiro2cc-proxy-src

# 2. Create config
cp config.example.json app/config/config.json
nano app/config/config.json   # Fill in adminPsw

# 3. Install (auto-compiles + registers systemd service)
sudo bash install_server.sh

The service starts automatically on boot. Common commands:

systemctl status kiro2cc-proxy       # Check status
systemctl restart kiro2cc-proxy      # Restart
systemctl stop kiro2cc-proxy         # Stop
journalctl -u kiro2cc-proxy -f       # Live logs

Option 4: Manual Background Process (No systemd)

bash start_server.sh start     # Start in background
bash start_server.sh status    # Check status
bash start_server.sh log       # Live logs
bash start_server.sh stop      # Stop
bash start_server.sh restart   # Restart

Proxy Configuration for Servers

Servers in mainland China cannot access Kiro API directly. Add a proxy to config.json:

{
  "proxyUrl": "http://your-proxy-host:port"
}

Using an overseas server is recommended — no proxy needed.


🔑 Getting Kiro Accounts

Full Flow: Export from Kiro Account Manager → Import via Admin Panel

Step 1: Export account JSON from Kiro Account Manager

  1. Install Kiro IDE or Kiro Account Manager (KAM) — download from the KAM Releases page
  2. Sign in with your GitHub / Google Social account
  3. Find the "Export Account" option in the account management interface
  4. Export as a JSON file (or copy the JSON content)

Step 2: Start the kiro2cc-proxy service

Follow the "Local Deployment" or "Server Deployment" section to start the service and confirm it is running.

Step 3: Import accounts with KAM Account Import (recommended)

  1. Open the admin panel: http://127.0.0.1:5678/admin (replace with your server IP for server deployments)
  2. Log in with the adminPsw (Admin Password) configured in config.json
  3. Go to the accounts management page
  4. Click KAM Account Import; the same entry supports both single-account and multi-account KAM export JSON
  5. Paste the exported JSON content into the input field, or drag and drop the .json file onto the page
  6. Click Import; accounts are created disabled, then the panel automatically runs quota verification
  7. Successfully verified accounts are enabled automatically; accounts that fail verification remain retained and disabled for configuration review

ℹ️ Importing accounts over HTTP

Since v2.7.3, a pure-JS fallback is built in, so importing accounts works fine even when accessing the admin panel via http://server-ip:port/admin (not HTTPS, not localhost) — no need to configure HTTPS or browser flags.

If you're on v2.7.2 or earlier, the browser's security policy still disables the crypto.subtle encryption API in this case, causing an error Cannot read properties of undefined (reading 'digest'). Please upgrade to the latest version.

Step 4 (optional): Create the accounts file manually

You can skip the admin panel and save the exported JSON directly as a file:

  • Local deployment: app/config/credentials.json
  • Docker deployment: data/credentials.json

See the format reference below. Restart the service after saving.

credentials.json Format

Social login (single account):

{
  "refreshToken": "your-refresh-token",
  "expiresAt": "2025-12-31T02:32:45.144Z",
  "authMethod": "social"
}

IDC/Builder-ID login (single account):

{
  "refreshToken": "your-refresh-token",
  "expiresAt": "2025-12-31T02:32:45.144Z",
  "authMethod": "idc",
  "clientId": "your-client-id",
  "clientSecret": "your-client-secret"
}

Multiple accounts (array format, with failover):

[
  {
    "refreshToken": "token-1",
    "expiresAt": "2025-12-31T02:32:45.144Z",
    "authMethod": "social",
    "priority": 0
  },
  {
    "refreshToken": "token-2",
    "expiresAt": "2025-12-31T02:32:45.144Z",
    "authMethod": "social",
    "priority": 1
  }
]

Lower priority value = higher priority. Up to 3 retries per account, 9 per request, with automatic failover.


⚙️ Configuration Reference

config.json Fields

Field Required Default Description
host No 127.0.0.1 Listen address; 0.0.0.0 allows external/LAN access
port No 8080 (5678 when written by the local setup scripts) Listen port; changes from the settings page are written to config.json and take effect after restart
region No us-east-1 AWS region
authRegion No same as region Region used for token refresh
apiRegion No same as region Region used for API requests
adminPsw No — Admin Password (admin panel login password); omit to disable admin panel
proxyUrl No — HTTP/SOCKS5 proxy, e.g. http://127.0.0.1:7890
proxyUsername No — Proxy username
proxyPassword No — Proxy password
tlsBackend No rustls TLS backend: rustls or native-tls
loadBalancingMode No priority priority (by priority) or balanced (round-robin)
maxRpmPerCredential No 0 Maximum requests per minute for each account; 0 means unlimited. Saving from the settings page applies it immediately and persists it to config.json
forwardSuggestionMode No false Suggestion Mode input-prediction switch. With the default false, the proxy intercepts Claude Code's automatic full-context prediction request after each turn and returns an empty response without Token usage. true forwards it upstream to show input suggestions, but each turn incurs one additional full-context billed request. Override with FORWARD_SUGGESTION_MODE
clientTokenPassthrough No true Client token passthrough: true (default) reports returned usage fields 1:1 with real values; false displays values scaled by 0.6657. It supports third-party clients that calculate context usage from returned usage values. Note: with true, Claude Code's auto-compact triggers at about 164K real context (about 246K with false); set false to keep the legacy trigger timing. Override with CLIENT_TOKEN_PASSTHROUGH
promptCacheAccounting No false Simulate prompt-cache accounting with Anthropic cache_control breakpoint rules. With true, cache_read / cache_creation (including the 5m/1h split) are derived from the request's breakpoints, the 20-block lookback window and TTLs, replacing the prefix estimate that counts everything before the last message as cache reads with zero writes. Requests without cache_control count as plain input (OpenAI-compatible endpoints use automatic prefix caching). The cache is isolated per API key (similar to Anthropic's workspace-level isolation) and keyed by the mapped Kiro model ID; the table is persisted to prompt_cache.json in the config directory and restored on restart. This is a local simulation: it only brings the downstream billing split closer to Anthropic's accounting and does not reflect Kiro's actual cache hits or real cost (credits remain the source of truth). Intended for downstream gateways that bill by usage. Override with PROMPT_CACHE_ACCOUNTING
promptCacheMinTokens No 0 Global override for the minimum cacheable prefix length (tokens). With 0 (default), Anthropic's per-model values apply: 512 for Opus 5.5 / Opus 5 / Sonnet 5.5 / Haiku 5.5 and similar, 2048 for Opus 4.7, 4096 for Opus 4.6 / Opus 4.5 / Haiku 4.5, and 1024 otherwise; a value > 0 applies to all models. Override with PROMPT_CACHE_MIN_TOKENS
modelsOfficialAliases No false With true, /v1/models appends official hyphenated aliases after upstream dotted model IDs (e.g. claude-opus-4.6 → claude-opus-4-6, plus dated IDs for the 4.5 generation), for downstream gateways that build model mappings from the list. Off by default to avoid duplicate entries in Claude Code's model picker. Override with MODELS_OFFICIAL_ALIASES
outputTokensIncludeThinking No false With true, the output_tokens returned to clients include thinking (matching Anthropic's official accounting); the default false counts visible output only. Override with OUTPUT_TOKENS_INCLUDE_THINKING
writeChunkingMaxLines No 300 Line limit of the chunked-writing instruction (see the Reset(StreamId(1), INTERNAL_ERROR, Remote) FAQ entry): when a request carries Write / Edit / MultiEdit, the system prompt asks for no more than ~N lines per tool call. Larger saves credits but makes the ~240s upstream stream reset more likely; 0 disables the instruction. Editable in the Admin settings page and hot-applied to subsequent requests. Override with WRITE_CHUNKING_MAX_LINES
thinkingAsText No true Thinking-as-text display for Claude Code only. true rewrites thinking blocks into text streamed line by line, similar to Kiro CLI: the terminal entrypoint cli uses ANSI dim italic (gray) styling, while other entrypoints such as Claude Desktop and local-agent use escape-free Markdown (a blockquote with italic lines) to approximate dimming and avoid [2m / [0m garbage. This avoids Claude Code appearing stalled while native thinking is folded. In both modes Claude Code's own context contains the thinking content, but it is dropped entirely when history is sent upstream: with the switch off, native thinking blocks are dropped; with it on, the marker line, thinking body and token-count line are dropped, so the upstream context never contains thinking (only when the stream is interrupted and the token-count line is missing does it conservatively fall back to stripping just the marker line). Override with THINKING_AS_TEXT
thinkingCollapse No true Collapse thinking when done (requires thinkingAsText; applies to the Claude Code terminal cli entrypoint and Claude Desktop, both verified; other entrypoints such as local-agent are unverified, so turn this off if thinking content is not visible). true keeps the line-by-line live preview, then when the thinking block ends the proxy emits a native thinking block on the same index. Claude Code clears the streaming text preview and lands it as a native collapsible thinking message (collapsed by default, Ctrl+O to expand; the expanded body ends with an "N tokens" line showing the thinking token count, the collapsed label is hardcoded by Claude Code and cannot show it), so the full thinking text no longer stays in the scrollback. Claude Desktop and similar entrypoints collapse into a native thinking block too, expanded through the client's own control. Can be overridden by the THINKING_COLLAPSE environment variable
showSessionCredits No false Session credits summary line (all clients, including OpenAI-compatible callers such as Codex CLI). true appends one line at the end of a reply once a conversation actually ends (end_turn; intermediate tool-call steps are skipped), e.g. ▸ Credits: turn 0.86 • session 8.73 | Time: 12s, matching Kiro CLI. turn is the credits spent in this turn (all requests under one prompt, including tool round-trips), session is the running total for the conversation since this was enabled, and Time is the turn duration. The upstream meteringEvent only reports per-request usage with no running total, so the proxy accumulates per request and resets on restart. Dimmed gray for the Claude Code cli entrypoint, escape-free Markdown italics for other entrypoints and non-Claude Code clients. The line is stripped before history is sent upstream, so it never enters the upstream context or output_tokens; for Claude Code, auxiliary requests without tool definitions (title generation, compaction, etc.) are skipped; json_schema structured-output requests are skipped for every client; other clients get the line on streaming requests even without tools (so a streamed title-generation call would show it too); non-streaming requests are not supported. Override with SHOW_SESSION_CREDITS
credentialKeepAliveHours No 72 Account keep-alive interval in hours. Account keep-alive is always on and has no switch: a background task periodically refreshes long-idle accounts (including disabled and standby ones) to keep their refreshToken active, and writes the rotated refreshToken back to the credentials file. An account is only kept alive once it was last refreshed longer ago than this value; values below 24 are treated as 24. Accounts are spaced 30-120 seconds apart, at most 5 per hour; failures are not retried and accounts revoked by the server are skipped. It only mitigates expiry caused by inactivity and cannot extend an absolute server-side session limit (such as IAM Identity Center's 90 days). Overridable via env var CREDENTIAL_KEEP_ALIVE_HOURS
debugLogs No false DEBUG log switch: when true, DEBUG-level events are emitted to the console, the log file (logFile) and the Admin Log Viewer page in sync; hot-switchable from the Admin settings page (no restart) and persisted to config.json. Switching it off stops capturing new DEBUG entries while already captured ones are kept. Note the switch reports/saves its own state, not the effective level: when RUST_LOG is set its directives still take precedence (the switch only appends a global debug directive on top of RUST_LOG; target-specific directives are unaffected). Log volume grows significantly — turn it off after troubleshooting. Override with DEBUG_LOGS

TLS note: If you encounter token refresh failures or request errors, try switching tlsBackend to native-tls.

Full example:

{
  "host": "0.0.0.0",
  "port": 8080,
  "region": "us-east-1",
  "adminPsw": "my-admin-password",
  "proxyUrl": "http://127.0.0.1:7890",
  "tlsBackend": "rustls",
  "loadBalancingMode": "priority",
  "maxRpmPerCredential": 0,
  "forwardSuggestionMode": false,
  "clientTokenPassthrough": true,
  "thinkingAsText": true,
  "debugLogs": false
}

Runtime Settings in the Admin Panel

After configuring adminPsw, the Admin settings page manages the following options. Each save persists the value to config.json.

Setting config.json field Behavior after saving
Suggestion Mode input suggestions forwardSuggestionMode Applies immediately
Client token passthrough clientTokenPassthrough Applies immediately
Thinking-as-text display thinkingAsText Applies immediately to subsequent requests only
Collapse thinking when done thinkingCollapse Applies immediately to subsequent requests only
Session credits summary line showSessionCredits Applies immediately to subsequent requests only
DEBUG logs debugLogs Applies immediately; console / log file / Log Viewer stay in sync
Per-account RPM limit maxRpmPerCredential Applies immediately; 0 means unlimited
Chunked-write line limit writeChunkingMaxLines Applies immediately to subsequent requests only; 0 disables the instruction
Listen port port Takes effect after restart; valid range: 1–65535
Upstream proxy URL proxyUrl Takes effect after restart; accepts http, https, and socks5; empty disables the proxy

Client authentication: config.json no longer provides a global API key. Clients calling /v1/messages or /cc/v1/messages must authenticate with a sub API key created and enabled in the admin panel (login with adminPsw). Note: if adminPsw is left unset, the admin panel itself is disabled — you won't be able to create sub API keys until it's configured.

Per-Account Proxy

Override the global proxy for individual accounts:

[
  {
    "refreshToken": "token-a",
    "authMethod": "social",
    "proxyUrl": "socks5://proxy-a.example.com:1080"
  },
  {
    "refreshToken": "token-b",
    "authMethod": "social",
    "proxyUrl": "direct"
  }
]

proxyUrl: "direct" forces direct connection for that account, ignoring any global proxy.

Per-Account Quota Reserve

Configure a reserve floor per account (also editable in Admin UI under Edit Account → Quota Protection). When remaining credits reach the floor, the account is automatically paused and traffic fails over to the next available account, recovering automatically on the next reset cycle:

[
  {
    "refreshToken": "token-a",
    "authMethod": "social",
    "reservePercent": 20,
    "reserveCredits": 1000
  }
]
  • reservePercent (optional, (0, 100)): percentage of the current plan total to reserve.
  • reserveCredits (optional, > 0): fixed credits amount to reserve.
  • When both are configured, the higher floor applies (max(usageLimit * reservePercent / 100, reserveCredits)).

Region Priority

Auth Region (token refresh): account.authRegion > account.region > config.authRegion > config.region

API Region (API requests): account.apiRegion > config.apiRegion > config.region


🤖 Claude Code Integration

Option 1: One-click import into CC Switch (recommended)

  • Admins: Admin panel → API Key Management, click the 🤖 icon on the target key's row
  • End users: Sign in to the user panel (/user) with your API key, then click "Import Claude Code" in the "One-click import into CC Switch" card

Option 2: Environment Variables

Set these environment variables in your terminal to route Claude Code through this proxy:

export ANTHROPIC_BASE_URL="http://127.0.0.1:5678"
export ANTHROPIC_API_KEY="API key created in the admin panel's API Key Management page"

Persist across sessions (add to ~/.zshrc or ~/.bashrc):

echo 'export ANTHROPIC_BASE_URL="http://127.0.0.1:5678"' >> ~/.zshrc
echo 'export ANTHROPIC_API_KEY="API key created on the admin panel API Key Management page"' >> ~/.zshrc
source ~/.zshrc

Option 3: settings.json

Configure the proxy directly in Claude Code's settings file — no need to set environment variables each time.

Config file locations:

  • Global: ~/.claude/settings.json
  • Per-project: <project-root>/.claude/settings.json (applies to current project only)

Add the following to the config file:

{
  "env": {
    "ANTHROPIC_BASE_URL": "http://127.0.0.1:5678",
    "ANTHROPIC_API_KEY": "API key created in the admin panel's API Key Management page"
  }
}

If the file already has other settings, merge the env field in:

{
  "theme": "dark",
  "env": {
    "ANTHROPIC_BASE_URL": "http://127.0.0.1:5678",
    "ANTHROPIC_API_KEY": "API key created in the admin panel's API Key Management page"
  }
}

Verify it works:

curl http://127.0.0.1:5678/v1/messages \
  -H "Content-Type: application/json" \
  -H "x-api-key: your-api-key" \
  -d '{
    "model": "claude-sonnet-4-20250514",
    "max_tokens": 100,
    "messages": [{"role": "user", "content": "hi"}]
  }'

🧬 Codex CLI / OpenAI SDK Integration

In addition to the Anthropic protocol, the proxy also exposes two OpenAI-compatible endpoints, so you can drive Codex CLI or any OpenAI SDK client with your Kiro quota. Both endpoints work by "translate + forward": the request is converted to Anthropic format and reuses the full /v1/messages downstream pipeline (multi-account failover, RPM counting, usage tracking, rate limiting), then the response is converted back to OpenAI format.

Codex CLI Setup

Option 1: One-click import into CC Switch (recommended)

  • Admins: Admin panel → API Key Management, click the ⌨️ icon on the target key's row
  • End users: Sign in to the user panel (/user) with your API key, then click "Import Codex" in the "One-click import into CC Switch" card

Option 2: Edit config.toml manually

Edit ~/.codex/config.toml (shared by the Codex CLI and the ChatGPT.app desktop client):

model = "gpt-5.6-terra"
model_provider = "kiro"

[model_providers.kiro]
name = "kiro2cc-proxy"
base_url = "http://127.0.0.1:5678/v1"  # 127.0.0.1 for local deployment; replace with your domain/public IP for server deployments
wire_api = "responses"        # recommended; or "chat"
env_key = "KIRO_API_KEY"

Put the key in ~/.codex/.env (Codex statically links the Rust dotenvy crate and reloads this file on every invocation — everything stays inside ~/.codex/, no shell environment variables needed, and changes take effect immediately without a restart):

echo 'KIRO_API_KEY=your-api-key' > ~/.codex/.env
chmod 600 ~/.codex/.env
codex

Avoid duplicate definitions: if you created a profile with -p/--profile <name> (~/.codex/<name>.config.toml), the profile is layered on top of config.toml — only fields explicitly set in the profile override the base config; everything else is inherited. If the profile's model / model_provider etc. are identical to the base config, the profile is redundant (verify by running codex exec once without -p and once with -p <name>, then diff the output) — just delete it instead of maintaining two copies.

ChatGPT.app desktop client reads the same config.toml (the top-level model_provider applies; there's currently no separate profile mechanism for the app), but it's a long-running process that loads the config once at startup — changing config.toml requires a full app restart to take effect. ~/.codex/.env, on the other hand, is re-read on every call, so edits apply immediately without restarting anything.

wire_api values:

Value Endpoint used Notes
responses /v1/responses Codex CLI's default protocol, most complete feature set (reasoning events, freeform tools)
chat /v1/chat/completions Generic Chat Completions protocol, widest compatibility

Both support streaming and tool-call round trips; responses is recommended for everyday use.

OpenAI SDK Setup

from openai import OpenAI

client = OpenAI(base_url="http://127.0.0.1:5678/v1", api_key="your-api-key")

resp = client.chat.completions.create(
    model="gpt-5.6-terra",
    messages=[{"role": "user", "content": "hello"}],
)
print(resp.choices[0].message.content)

Model name can be gpt-6.2-astra / gpt-6-luna / gpt-5.6-terra / gpt-5.6-luna / gpt-5.6-sol, or any claude-* model name (passed through as-is to upstream). Codex CLI's built-in gpt-5-codex / gpt-5.1-codex auto-map to gpt-5.6-terra, and gpt-5.1-codex-max maps to gpt-5.6-luna.

Known Limitations

  • previous_response_id is not supported — the proxy is stateless and doesn't persist prior responses. Requests containing this field return 400 immediately without an upstream call; send the full conversation history in input instead (Codex CLI already does this by default, no extra config needed).
  • tool_choice only supports auto — other values (required or a specific function name) are logged as WARN and treated as auto; this is an existing limitation of the upstream Kiro API.
  • reasoning.effort has no effect on gpt-5.6-luna — this model always returns thinking=0 upstream.
  • include: ["reasoning.encrypted_content"] is ignored — the proxy doesn't produce encrypted reasoning content.

🔌 API Endpoints

Standard Endpoints (/v1)

Endpoint Method Description
/v1/models GET List available models
/v1/messages POST Create a message (chat)
/v1/messages/count_tokens POST Estimate token count

OpenAI Compatible Endpoints (/v1)

Endpoint Method Description
/v1/chat/completions POST OpenAI Chat Completions protocol; supports streaming, tool calls, reasoning_effort
/v1/responses POST OpenAI Responses protocol; Codex CLI's default wire_api

See 🧬 Codex CLI / OpenAI SDK Integration for details.

Claude Code Compatible Endpoints (/cc/v1)

Endpoint Method Description
/cc/v1/messages POST Buffered mode with accurate input_tokens
/cc/v1/messages/count_tokens POST Estimate token count

/cc/v1/messages waits for the full upstream stream to complete before returning. input_tokens uses the actual value rather than an estimate. Sends a ping keepalive every 25 seconds while waiting.

Client Authentication

Two methods supported:

x-api-key: your-api-key

or

Authorization: Bearer your-api-key

🗺️ Model Mapping

Any model name containing the following keywords is automatically mapped to the corresponding Kiro model:

Request model name (keyword) Kiro model used
*sonnet* (including 5.5/5-5) claude-sonnet-5.5
*sonnet* (including 4.6/4-6) claude-sonnet-4.6
*sonnet* (including 5/sonnet-5) claude-sonnet-5
*sonnet* (others) claude-sonnet-4.5
*opus* (including 5.5/5-5) claude-opus-5.5
*opus* (including 5/opus-5) claude-opus-5
*opus* (including 4.5/4-5) claude-opus-4.5
*opus* (including 4.7/4-7) claude-opus-4.7
*opus* (including 4.8/4-8) claude-opus-4.8
*opus* (others) claude-opus-4.6
*fable* (including 5.2/5-2) claude-fable-5.2
*fable* (including 5.1/5-1) claude-fable-5.1
*fable* (others) claude-fable-5
*haiku* (including 5.5/5-5) claude-haiku-5.5
*haiku* claude-haiku-4.5
*deepseek* deepseek-3.2
*glm* glm-5
*minimax* (including 2.5/2-5) minimax-m2.5
*minimax* (others) minimax-m2.1
*qwen* qwen3-coder-next
*kimi* kimi-k3
*grok* grok-4.7
*ergo* amazon-ergo
*gpt* (including astra, or 6.2/6-2) gpt-6.2-astra
*gpt* (including luna with a version 6 marker, e.g. gpt-6-luna) gpt-6-luna
*gpt* (including terra) gpt-5.6-terra
*gpt* (including luna) gpt-5.6-luna
*gpt* (including sol, or 5.6/5-6 without a variant name, defaults to the flagship tier) gpt-5.6-sol

🛡️ Admin Panel

When adminPsw is configured, access the admin panel at http://127.0.0.1:5678/admin.

Features:

  • View all account statuses (validity, failure count, etc.)
  • Add / delete accounts
  • Import one or multiple KAM accounts through KAM Account Import with automatic quota verification
  • Enable / disable individual accounts
  • Adjust account priority
  • Check account balance
  • Reset account failure state
  • Documentation page: client config generation (Claude Code / Codex CLI / OpenAI SDK / one-click CC Switch import), API reference and troubleshooting (examples auto-filled with the selected API key)

Admin API (requires x-api-key or Authorization: Bearer header):

Endpoint Method Description
/api/admin/credentials GET List all accounts
/api/admin/credentials POST Add an account
/api/admin/credentials/:id DELETE Delete an account
/api/admin/credentials/:id/balance GET Query balance

❓ FAQ

Q: Service starts but shows "0 accounts loaded"

Create app/config/credentials.json (local) or data/credentials.json (Docker). See the "Getting Kiro Accounts" section.

Q: Requests return INVALID_MODEL_ID

⚠️ [CRITICAL] Mainland China IPs cannot access Claude models directly. You must add proxyUrl to app/config/config.json (e.g. "proxyUrl": "http://127.0.0.1:7890"), or use an overseas server. This is the most common issue for users in China.

Q: When using GPT-5.6 models (sol/terra/luna), thinking mode / output effort / max_tokens settings seem to have no effect

The Kiro backend schema for the GPT-5.6 series does not support additionalModelRequestFields (covering the thinking / output_config effort / max_tokens sub-fields) — same as the Claude 4.5 generation (Sonnet 4.5 / Opus 4.5 / Haiku 4.5), this field is skipped entirely. This is a known upstream limitation, not a bug in this project.

Q: Requests return 401 Unauthorized

Check whether the client is using a sub API key that was created and enabled in the admin panel — disabled or deleted keys are rejected.

Q: Token refresh fails / request errors

Try changing tlsBackend to native-tls in config.json and restart the service.

Q: Importing accounts via the admin panel fails with Cannot read properties of undefined (reading 'digest')

This was fixed in v2.7.3: the crypto.subtle encryption API is only available in HTTPS or localhost environments, so accessing the admin panel via a public IP + HTTP used to trigger this error. Since v2.7.3, it automatically falls back to a pure-JS implementation — no need to configure HTTPS. If you still see this error, please upgrade to the latest version.

Q: Enterprise IdC account requests return 502 with profileArn is required for this request in the logs

Enterprise IdC accounts calling the Q endpoint require a profileArn, but the IdC token refresh response doesn't include it — it must be entered manually. The admin panel's "Add Account / Edit Account" dialog now has a Profile ARN field; fill in a value like arn:aws:codewhisperer:<region>:<account-id>:profile/<profile-id>. You can obtain the profileArn from the Kiro IDE local cache or via ListAvailableProfiles; its region must match the account's apiRegion. Social accounts usually don't need this field.

Q: After filling in profileArn, an Enterprise IdC account still returns 403 Forbidden: Invalid token when checking balance

This has been fixed: the AWS SSO OIDC refresh endpoint returns both an accessToken (SSO portal session token) and an idToken (JWT). The Amazon Q data-plane endpoint (chat requests) only accepts the idToken, while the usage/quota endpoint (getUsageLimits) requires the original accessToken — previously the proxy only kept a single token and reused it for both, so only one of the two could work at a time. After the fix, the proxy stores both tokens separately and picks the right one per endpoint, with no action needed from you; it takes effect automatically after the account's next token refresh (credentials.json gains an internal ssoAccessToken field, fully backward compatible with existing config files — no manual editing required). If it still fails after upgrading, try resetting the account in the admin panel or wait for the token to expire and refresh automatically.

Q: Can sub-API-Key spending limits be metered in real Kiro credits instead of estimated USD?

Yes. When creating/editing a sub API Key, the limit unit can be set to "USD estimate" or "real credits" (limitUnit: usd/credits). With credits, the limit is checked against the real credits_used accumulated in usage records (falls back to estimated_cost × k_ref for older records without credits_used). Defaults to usd, fully backward compatible.

Q: After a long generation of about 4 minutes (~247s) the client reports Server error mid-response, and the proxy log shows Reset(StreamId(1), INTERNAL_ERROR, Remote)

The upstream (Kiro gateway) reset the HTTP/2 stream; this is not a proxy timeout (the proxy's upstream timeout is 1000s). If some output was already produced when the reset arrives, the proxy immediately sends an overloaded_error to the client (it never disguises the interruption as a normal completion), and the client then retries automatically. The issue also reproduces when using the Kiro CLI directly against the upstream, without this proxy, which confirms the root cause is on the upstream side — unrelated to the proxy's forwarding path or the client.

A reproducible trigger was found in testing: the model generates a very large tool-call argument in one go (typically a single Write of tens of thousands of characters). The upstream does not stream tool arguments incrementally, so the stream carries no data while the call is being generated, and after about 240s of silence the upstream resets it with RST_STREAM(INTERNAL_ERROR) (in tests a write of ~8,000 characters took ~215s and succeeded, ~20,000 characters failed at ~240s every time, independent of the thinking-adaptive switch; retrying the same request fails again; HTTP/2 PING keep-alive does not help). Plain text streams and the thinking phase emit data continuously and finished normally after 794s.

What the proxy does: when a request carries any of the Write / Edit / MultiEdit tools, it appends a fixed chunked-writing instruction to the end of the system prompt (no more than ~N lines per call, N defaults to 300 and is set by writeChunkingMaxLines: Write content, Edit new_string, and the combined content of all edits inside one MultiEdit call all count toward the limit; for larger content, write the first part with Write and append the rest with several Edit / Bash calls, and split a large MultiEdit into several calls), so the model splits big changes into several calls. For Write, all 4 large-file write requests in tests then finished normally within about 2 minutes (Edit / MultiEdit have not been validated separately). The client's tool descriptions are not modified.

Trade-off (follow-up on issue #46): the instruction makes the model split one large write into several turns, and the client sends thinking: adaptive on every turn, so the model re-thinks each time. A user's own statistics show about 3x the credits for comparable tasks (not reproduced by me). The limit is therefore configurable via writeChunkingMaxLines: a larger value saves credits but makes the ~240s upstream stream reset more likely; a smaller value is safer but costs more; 0 stops appending the instruction (you then control write size yourself). The default 300 is an estimate derived from the output speed measured in the issue (~8000 CJK characters in ~215s succeeds, ~20000 in ~240s always fails) and has not been verified with a real Claude Code; lower it if you still see resets. It can be changed in the Admin settings page (hot-applied to subsequent requests); WRITE_CHUNKING_MAX_LINES overrides it.

It can still happen when the model ignores the instruction, or when several write-type tools are called in parallel within one turn (each within the limit but too slow in total; this case has not been tested). In that case ask the model to write in pieces, or attach the log to the issue (the stream_elapsed_secs field records how long the stream had run when it broke). Note: this is based on local tests (single account, Opus 4.6, SOCKS5 egress); the issue reporter's environment has not been verified.

Note: agentContinuationId is a session-stable identifier the proxy derives from the conversationId (used for prompt cache and sticky account routing); it is not an upstream "resume" handle, so the proxy cannot continue the remaining output after a Reset. The proxy already sends a ping to the client every 25 seconds, but the Reset originates on the upstream side, so client-side keep-alive cannot prevent it.

Q: Port already in use

run-local-service-mac.sh automatically kills the process occupying the configured port. If it still fails:

lsof -ti:5678 | xargs kill -9

Q: Write Failed / session hangs

Output truncated due to excessive length. Lower the max_tokens limit in your client.

Q: Credits usage increased after enabling Claude Code's Auto permission mode

This is behavior of the Claude Code client itself, not a proxy bug. Auto mode prefers Anthropic's server-side classifier. When connected to a third-party endpoint (including this proxy), the client receives no server-side classification, so it falls back to a local classifier for the rest of the session. Before each sensitive tool call (such as running a command), it sends 1–2 extra non-streaming /v1/messages requests to decide whether to allow the action. The proxy forwards them to Kiro upstream like any other request, so they are billed as normal Credits.

These requests typically have an empty tools list, max_tokens of 64 or 8192, and a last user message starting with <transcript>. They show up in the [small-req] diagnostic log. The classifier defaults to a Sonnet-tier model, regardless of the model used for the main conversation.

The proxy does not intercept these requests or fake their results, since that would approve every command on the user's behalf and bypass Auto mode's safety checks. Options to reduce the cost:

  • Set CLAUDE_CODE_AUTO_MODE_MODEL=claude-haiku-4.5 in the client environment so the classifier uses a cheaper model. This variable only affects the client-side local classifier. Note: the Code tab in Claude Desktop currently ignores this variable (see anthropics/claude-code#105288), so the classifier still uses the session model.
  • In fully trusted projects, switch to Bypass Permissions mode, which sends no classifier requests. This mode performs no safety checks, so assess the risk yourself.

Q: Other devices on LAN can't connect

Set host to 0.0.0.0 in config.json and ensure your firewall allows the port.

Q: How to update to the latest version (Docker deployment)

GHCR image deployments do not require source updates. Back up data/, then run:

cd /opt/kiro2cc-proxy
docker compose pull
docker compose up -d

For a pinned version, first change the image tag in docker-compose.yml to the desired published version. Keep the original data/ mount.

Q: How to update to the latest version (local deployment)

git pull
./build-and-run-mac.sh   # or run separately: ./build-mac.sh && ./run-local-service-mac.sh

⚠️ Notes

  1. credentials.json contains sensitive tokens — never commit it to version control or share it
  2. The service auto-refreshes expired tokens — no manual intervention needed
  3. In multi-account mode, refreshed tokens are automatically written back to the file
  4. Mainland China users must configure a proxy to access Claude models

📂 Project Structure

kiro2cc-proxy/
├── src/                    # Rust source code
├── web-ui/                 # Web frontends root
│   ├── admin-ui/           # Admin panel frontend
│   └── user-ui/            # User panel frontend
├── app/config/             # Local config directory (gitignored)
├── config.example.json     # Config example
├── docker-compose.yml      # Docker deployment config
├── Dockerfile              # Docker image build
├── build-mac.sh            # One-click build script (macOS)
├── build-windows.ps1       # One-click build script (Windows)
├── build-and-run-mac.sh            # One-click build-and-run script (macOS)
├── build-and-run-windows.ps1       # One-click build-and-run script (Windows)
├── run-local-service-mac.sh         # macOS local startup script
├── run-local-service-windows.ps1   # Windows local startup script
├── setup_shell_aliases.sh  # macOS shell alias installer
├── setup_shell_aliases.ps1 # Windows PowerShell alias installer
├── install_server.sh       # Linux systemd one-click install
└── start_server.sh         # Linux manual background process manager

📜 License

MIT

🙏 Acknowledgements

This project is based on kiro.rs. Thanks to the original author for the open-source contribution.

Thanks to all the contributors of this project (in no particular order):

thanks — the following issues directly drove critical fixes:

Thanks to everyone who has filed issues, shared feedback, and joined the discussions — you keep making this project better.

Explore related projects

Loading…