File size: 18,727 Bytes
bf9e111 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 | <div align="center">
# ๐ป Kiro Gateway
**Proxy gateway for Kiro API (Amazon Q Developer / AWS CodeWhisperer)**
[๐ท๐บ ะ ัััะบะธะน](docs/ru/README.md) โข [๐จ๐ณ ไธญๆ](docs/zh/README.md) โข [๐ช๐ธ Espaรฑol](docs/es/README.md) โข [๐ฎ๐ฉ Indonesia](docs/id/README.md) โข [๐ง๐ท Portuguรชs](docs/pt/README.md) โข [๐ฏ๐ต ๆฅๆฌ่ช](docs/ja/README.md) โข [๐ฐ๐ท ํ๊ตญ์ด](docs/ko/README.md)
Made with โค๏ธ by [@Jwadow](https://github.com/jwadow)
[](https://www.gnu.org/licenses/agpl-3.0)
[](https://www.python.org/downloads/)
[](https://fastapi.tiangolo.com/)
[](#-support-the-project)
*Use Claude models from Kiro with Claude Code, OpenCode, Cursor, Cline, Roo Code, Kilo Code, Obsidian, OpenAI SDK, LangChain, Continue and other OpenAI or Anthropic compatible tools*
[Models](#-supported-models) โข [Features](#-features) โข [Quick Start](#-quick-start) โข [Configuration](#%EF%B8%8F-configuration) โข [๐ Sponsor](#-support-the-project)
</div>
---
## ๐ค Available Models
> โ ๏ธ **Important:** Model availability depends on your Kiro tier (free/paid). The gateway provides access to whatever models are available in your IDE or CLI based on your subscription. The list below shows models commonly available on the **free tier**.
> ๐ **Claude Opus 4.5** was removed from the free tier on January 17, 2026. It may be available on paid tiers โ check your IDE/CLI model list.
๐ **Claude Sonnet 4.5** โ Balanced performance. Great for coding, writing, and general-purpose tasks.
โก **Claude Haiku 4.5** โ Lightning fast. Perfect for quick responses, simple tasks, and chat.
๐ฆ **Claude Sonnet 4** โ Previous generation. Still powerful and reliable for most use cases.
๐ฆ **Claude 3.7 Sonnet** โ Legacy model. Available for backward compatibility.
> ๐ก **Smart Model Resolution:** Use any model name format โ `claude-sonnet-4-5`, `claude-sonnet-4.5`, or even versioned names like `claude-sonnet-4-5-20250929`. The gateway normalizes them automatically.
---
## โจ Features
| Feature | Description |
|---------|-------------|
| ๐ **OpenAI-compatible API** | Works with any OpenAI-compatible tool |
| ๐ **Anthropic-compatible API** | Native `/v1/messages` endpoint |
| ๐ **VPN/Proxy Support** | HTTP/SOCKS5 proxy for restricted networks |
| ๐ง **Extended Thinking** | Reasoning is exclusive to our project |
| ๐๏ธ **Vision Support** | Send images to model |
| ๐ ๏ธ **Tool Calling** | Supports function calling |
| ๐ฌ **Full message history** | Passes complete conversation context |
| ๐ก **Streaming** | Full SSE streaming support |
| ๐ **Retry Logic** | Automatic retries on errors (403, 429, 5xx) |
| ๐ **Extended model list** | Including versioned models |
| ๐ **Smart token management** | Automatic refresh before expiration |
---
## ๐ Quick Start
### Prerequisites
- Python 3.10+
- One of the following:
- [Kiro IDE](https://kiro.dev/) with logged in account, OR
- [Kiro CLI](https://kiro.dev/cli/) with AWS SSO (AWS IAM Identity Center, OIDC) - free Builder ID or corporate account
### Installation
```bash
# Clone the repository (requires Git)
git clone https://github.com/Jwadow/kiro-gateway.git
cd kiro-gateway
# Or download ZIP: Code โ Download ZIP โ extract โ open kiro-gateway folder
# Install dependencies
pip install -r requirements.txt
# Configure (see Configuration section)
cp .env.example .env
# Copy and edit .env with your credentials
# Start the server
python main.py
# Or with custom port (if 8000 is busy)
python main.py --port 9000
```
The server will be available at `http://localhost:8000`
---
## โ๏ธ Configuration
### Option 1: JSON Credentials File (Kiro IDE / Enterprise)
Specify the path to the credentials file:
Works with:
- **Kiro IDE** (standard) - for personal accounts
- **Enterprise** - for corporate accounts with SSO
```env
KIRO_CREDS_FILE="~/.aws/sso/cache/kiro-auth-token.json"
# Password to protect YOUR proxy server (make up any secure string)
# You'll use this as api_key when connecting to your gateway
PROXY_API_KEY="my-super-secret-password-123"
```
<details>
<summary>๐ JSON file format</summary>
```json
{
"accessToken": "eyJ...",
"refreshToken": "eyJ...",
"expiresAt": "2025-01-12T23:00:00.000Z",
"profileArn": "arn:aws:codewhisperer:us-east-1:...",
"region": "us-east-1",
"clientIdHash": "abc123..." // Optional: for corporate SSO setups
}
```
> **Note:** If you have two JSON files in `~/.aws/sso/cache/` (e.g., `kiro-auth-token.json` and a file with a hash name), use `kiro-auth-token.json` in `KIRO_CREDS_FILE`. The gateway will automatically load the other file.
</details>
### Option 2: Environment Variables (.env file)
Create a `.env` file in the project root:
```env
# Required
REFRESH_TOKEN="your_kiro_refresh_token"
# Password to protect YOUR proxy server (make up any secure string)
PROXY_API_KEY="my-super-secret-password-123"
# Optional
PROFILE_ARN="arn:aws:codewhisperer:us-east-1:..."
KIRO_REGION="us-east-1"
```
### Option 3: AWS SSO Credentials (kiro-cli / Enterprise)
If you use `kiro-cli` or Kiro IDE with AWS SSO (AWS IAM Identity Center), the gateway will automatically detect and use the appropriate authentication.
Works with both free Builder ID accounts and corporate accounts.
```env
KIRO_CREDS_FILE="~/.aws/sso/cache/your-sso-cache-file.json"
# Password to protect YOUR proxy server
PROXY_API_KEY="my-super-secret-password-123"
# Note: PROFILE_ARN is NOT needed for AWS SSO (Builder ID and corporate accounts)
# The gateway will work without it
```
<details>
<summary>๐ AWS SSO JSON file format</summary>
AWS SSO credentials files (from `~/.aws/sso/cache/`) contain:
```json
{
"accessToken": "eyJ...",
"refreshToken": "eyJ...",
"expiresAt": "2025-01-12T23:00:00.000Z",
"region": "us-east-1",
"clientId": "...",
"clientSecret": "..."
}
```
**Note:** AWS SSO (Builder ID and corporate accounts) users do NOT need `profileArn`. The gateway will work without it (if specified, it will be ignored).
</details>
<details>
<summary>๐ How it works</summary>
The gateway automatically detects the authentication type based on the credentials file:
- **Kiro Desktop Auth** (default): Used when `clientId` and `clientSecret` are NOT present
- Endpoint: `https://prod.{region}.auth.desktop.kiro.dev/refreshToken`
- **AWS SSO (OIDC)**: Used when `clientId` and `clientSecret` ARE present
- Endpoint: `https://oidc.{region}.amazonaws.com/token`
No additional configuration is needed โ just point to your credentials file!
</details>
### Option 4: kiro-cli SQLite Database
If you use `kiro-cli` and prefer to use its SQLite database directly:
```env
KIRO_CLI_DB_FILE="~/.local/share/kiro-cli/data.sqlite3"
# Password to protect YOUR proxy server
PROXY_API_KEY="my-super-secret-password-123"
# Note: PROFILE_ARN is NOT needed for AWS SSO (Builder ID and corporate accounts)
# The gateway will work without it
```
<details>
<summary>๐ Database locations</summary>
| CLI Tool | Database Path |
|----------|---------------|
| kiro-cli | `~/.local/share/kiro-cli/data.sqlite3` |
| amazon-q-developer-cli | `~/.local/share/amazon-q/data.sqlite3` |
The gateway reads credentials from the `auth_kv` table which stores:
- `kirocli:odic:token` or `codewhisperer:odic:token` โ access token, refresh token, expiration
- `kirocli:odic:device-registration` or `codewhisperer:odic:device-registration` โ client ID and secret
Both key formats are supported for compatibility with different kiro-cli versions.
</details>
### Getting Credentials
**For Kiro IDE users:**
- Log in to Kiro IDE and use Option 1 above (JSON credentials file)
- The credentials file is created automatically after login
**For Kiro CLI users:**
- Log in with `kiro-cli login` and use Option 3 or Option 4 above
- No manual token extraction needed!
<details>
<summary>๐ง Advanced: Manual token extraction</summary>
If you need to manually extract the refresh token (e.g., for debugging), you can intercept Kiro IDE traffic:
- Look for requests to: `prod.us-east-1.auth.desktop.kiro.dev/refreshToken`
</details>
---
## ๐ VPN/Proxy Support
**For users in China, corporate networks, or regions with connectivity issues to AWS services.**
The gateway supports routing all Kiro API requests through a VPN or proxy server. This is essential if you experience connection problems to AWS endpoints or need to use a corporate proxy.
### Configuration
Add to your `.env` file:
```env
# HTTP proxy
VPN_PROXY_URL=http://127.0.0.1:7890
# SOCKS5 proxy
VPN_PROXY_URL=socks5://127.0.0.1:1080
# With authentication (corporate proxies)
VPN_PROXY_URL=http://username:password@proxy.company.com:8080
# Without protocol (defaults to http://)
VPN_PROXY_URL=192.168.1.100:8080
```
### Supported Protocols
- โ
**HTTP** โ Standard proxy protocol
- โ
**HTTPS** โ Secure proxy connections
- โ
**SOCKS5** โ Advanced proxy protocol (common in VPN software)
- โ
**Authentication** โ Username/password embedded in URL
### When You Need This
| Situation | Solution |
|-----------|----------|
| Connection timeouts to AWS | Use VPN/proxy to route traffic |
| Corporate network restrictions | Configure your company's proxy |
| Regional connectivity issues | Use a VPN service with proxy support |
| Privacy requirements | Route through your own proxy server |
### Popular VPN Software with Proxy Support
Most VPN clients provide a local proxy server you can use:
- **Sing-box** โ Modern VPN client with HTTP/SOCKS5 proxy
- **Clash** โ Usually runs on `http://127.0.0.1:7890`
- **V2Ray** โ Configurable SOCKS5/HTTP proxy
- **Shadowsocks** โ SOCKS5 proxy support
- **Corporate VPN** โ Check your IT department for proxy settings
Leave `VPN_PROXY_URL` empty (default) if you don't need proxy support.
---
## ๐ก API Reference
### Endpoints
| Endpoint | Method | Description |
|----------|--------|-------------|
| `/` | GET | Health check |
| `/health` | GET | Detailed health check |
| `/v1/models` | GET | List available models |
| `/v1/chat/completions` | POST | OpenAI Chat Completions API |
| `/v1/messages` | POST | Anthropic Messages API |
---
## ๐ก Usage Examples
### OpenAI API
<details>
<summary>๐น Simple cURL Request</summary>
```bash
curl http://localhost:8000/v1/chat/completions \
-H "Authorization: Bearer my-super-secret-password-123" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-5",
"messages": [{"role": "user", "content": "Hello!"}],
"stream": true
}'
```
> **Note:** Replace `my-super-secret-password-123` with the `PROXY_API_KEY` you set in your `.env` file.
</details>
<details>
<summary>๐น Streaming Request</summary>
```bash
curl http://localhost:8000/v1/chat/completions \
-H "Authorization: Bearer my-super-secret-password-123" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-5",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is 2+2?"}
],
"stream": true
}'
```
</details>
<details>
<summary>๐ ๏ธ With Tool Calling</summary>
```bash
curl http://localhost:8000/v1/chat/completions \
-H "Authorization: Bearer my-super-secret-password-123" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-5",
"messages": [{"role": "user", "content": "What is the weather in London?"}],
"tools": [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get weather for a location",
"parameters": {
"type": "object",
"properties": {
"location": {"type": "string", "description": "City name"}
},
"required": ["location"]
}
}
}]
}'
```
</details>
<details>
<summary>๐ Python OpenAI SDK</summary>
```python
from openai import OpenAI
client = OpenAI(
base_url="http://localhost:8000/v1",
api_key="my-super-secret-password-123" # Your PROXY_API_KEY from .env
)
response = client.chat.completions.create(
model="claude-sonnet-4-5",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"}
],
stream=True
)
for chunk in response:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")
```
</details>
<details>
<summary>๐ฆ LangChain</summary>
```python
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
base_url="http://localhost:8000/v1",
api_key="my-super-secret-password-123", # Your PROXY_API_KEY from .env
model="claude-sonnet-4-5"
)
response = llm.invoke("Hello, how are you?")
print(response.content)
```
</details>
### Anthropic API
<details>
<summary>๐น Simple cURL Request</summary>
```bash
curl http://localhost:8000/v1/messages \
-H "x-api-key: my-super-secret-password-123" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-5",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Hello!"}]
}'
```
> **Note:** Anthropic API uses `x-api-key` header instead of `Authorization: Bearer`. Both are supported.
</details>
<details>
<summary>๐น With System Prompt</summary>
```bash
curl http://localhost:8000/v1/messages \
-H "x-api-key: my-super-secret-password-123" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-5",
"max_tokens": 1024,
"system": "You are a helpful assistant.",
"messages": [{"role": "user", "content": "Hello!"}]
}'
```
> **Note:** In Anthropic API, `system` is a separate field, not a message.
</details>
<details>
<summary>๐ก Streaming</summary>
```bash
curl http://localhost:8000/v1/messages \
-H "x-api-key: my-super-secret-password-123" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-5",
"max_tokens": 1024,
"stream": true,
"messages": [{"role": "user", "content": "Hello!"}]
}'
```
</details>
<details>
<summary>๐ Python Anthropic SDK</summary>
```python
import anthropic
client = anthropic.Anthropic(
api_key="my-super-secret-password-123", # Your PROXY_API_KEY from .env
base_url="http://localhost:8000"
)
# Non-streaming
response = client.messages.create(
model="claude-sonnet-4-5",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello!"}]
)
print(response.content[0].text)
# Streaming
with client.messages.stream(
model="claude-sonnet-4-5",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello!"}]
) as stream:
for text in stream.text_stream:
print(text, end="", flush=True)
```
</details>
---
## ๐ง Debugging
Debug logging is **disabled by default**. To enable, add to your `.env`:
```env
# Debug logging mode:
# - off: disabled (default)
# - errors: save logs only for failed requests (4xx, 5xx) - recommended for troubleshooting
# - all: save logs for every request (overwrites on each request)
DEBUG_MODE=errors
```
### Debug Modes
| Mode | Description | Use Case |
|------|-------------|----------|
| `off` | Disabled (default) | Production |
| `errors` | Save logs only for failed requests (4xx, 5xx) | **Recommended for troubleshooting** |
| `all` | Save logs for every request | Development/debugging |
### Debug Files
When enabled, requests are logged to the `debug_logs/` folder:
| File | Description |
|------|-------------|
| `request_body.json` | Incoming request from client (OpenAI format) |
| `kiro_request_body.json` | Request sent to Kiro API |
| `response_stream_raw.txt` | Raw stream from Kiro |
| `response_stream_modified.txt` | Transformed stream (OpenAI format) |
| `app_logs.txt` | Application logs for the request |
| `error_info.json` | Error details (only on errors) |
---
## ๐ License
This project is licensed under the **GNU Affero General Public License v3.0 (AGPL-3.0)**.
This means:
- โ
You can use, modify, and distribute this software
- โ
You can use it for commercial purposes
- โ ๏ธ **You must disclose source code** when you distribute the software
- โ ๏ธ **Network use is distribution** โ if you run a modified version on a server and let others interact with it, you must make the source code available to them
- โ ๏ธ Modifications must be released under the same license
See the [LICENSE](LICENSE) file for the full license text.
### Why AGPL-3.0?
AGPL-3.0 ensures that improvements to this software benefit the entire community. If you modify this gateway and deploy it as a service, you must share your improvements with your users.
### Contributor License Agreement (CLA)
By submitting a contribution to this project, you agree to the terms of our [Contributor License Agreement (CLA)](CLA.md). This ensures that:
- You have the right to submit the contribution
- You grant the maintainer rights to use and relicense your contribution
- The project remains legally protected
---
## ๐ Support the Project
<div align="center">
<img src="https://raw.githubusercontent.com/Tarikul-Islam-Anik/Animated-Fluent-Emojis/master/Emojis/Smilies/Smiling%20Face%20with%20Hearts.png" alt="Love" width="80" />
**If this project saved you time or money, consider supporting it!**
Every contribution helps keep this project alive and growing
<br>
### ๐ค Donate
[**โ One-time Donation**](https://app.lava.top/jwadow?tabId=donate) โข [**๐ Monthly Support**](https://app.lava.top/jwadow?tabId=subscriptions)
<br>
### ๐ช Or send crypto
| Currency | Network | Address |
|:--------:|:-------:|:--------|
| **USDT** | TRC20 | `TSVtgRc9pkC1UgcbVeijBHjFmpkYHDRu26` |
| **BTC** | Bitcoin | `12GZqxqpcBsqJ4Vf1YreLqwoMGvzBPgJq6` |
| **ETH** | Ethereum | `0xc86eab3bba3bbaf4eb5b5fff8586f1460f1fd395` |
| **SOL** | Solana | `9amykF7KibZmdaw66a1oqYJyi75fRqgdsqnG66AK3jvh` |
| **TON** | TON | `UQBVh8T1H3GI7gd7b-_PPNnxHYYxptrcCVf3qQk5v41h3QTM` |
</div>
---
## โ ๏ธ Disclaimer
This project is not affiliated with, endorsed by, or sponsored by Amazon Web Services (AWS), Anthropic, or Kiro IDE. Use at your own risk and in compliance with the terms of service of the underlying APIs.
---
<div align="center">
**[โฌ Back to Top](#-kiro-gateway)**
</div>
|