Automated Kiro (AWS Builder ID OIDC) account provisioning pipeline → 9Router LLM gateway integration
End-to-end, browser-automated registration of AWS Builder ID accounts with automatic integration into the 9Router LLM gateway. Fully scripted: temp inbox → OIDC device flow → camofox browser signup → token persistence → gateway insertion.
- Overview
- Features
- Why This Exists
- Architecture
- Requirements
- Installation
- Usage
- CLI Reference
- How It Works
- 9Router Integration
- Project Structure
- Troubleshooting
- Security
- Roadmap
- Contributing
- Disclaimer
- License
Kiro Generator automates the complete lifecycle of AWS Builder ID accounts used to access AI coding services (CodeWhisperer / Kiro). From a single CLI invocation it:
- Creates a disposable inbox through Cloudflare-hosted temp-mail domains.
- Registers an OAuth 2.0 client against the AWS OIDC identity provider.
- Drives a camofox browser session (anti-bot-detection Chromium) through the device-authorization consent flow — email, name, OTP, password, allow.
- Persists the resulting
accessToken/refreshTokenpair to local account state. - Inserts a fully-populated provider connection into 9Router's SQLite database so the
account's models appear in the gateway's
/v1/modelscatalog.
It also ships a model probing helper (test_models.py) for smoke-testing any candidate
model through the OpenAI-compatible gateway endpoint.
Current status (August 2026): Kiro models (
kr/*) appear in the 9Router catalog but cannot be used for chat completions — free AWS Builder ID accounts do not carry aprofileArn, so CodeWhisperer requests fail with400 profileArn is required. This repository remains a complete, working reference implementation of the AWS Builder ID OIDC + 9Router provider integration flow, and the scripts are provider-agnostic enough to be adapted once a qualifying account type is available.
| Feature | Description |
|---|---|
| 🧬 Full browser registration | Headless camofox session drives the entire AWS consent flow — no manual steps |
| 📧 Disposable inbox | Random temp-mail addresses from 4 Cloudflare domains via cloudmail_client |
| 🔑 AWS OIDC token lifecycle | Device-code flow, token polling with retry, and refresh-token rotation |
| 🔌 9Router integration | Complete providerConnections row (authMethod, clientId, clientSecret, region, tokenEndpoint, scope) |
| 💾 Persistent state | Per-account JSON under accounts/kiro/, batch resume supported |
| 🧪 Model probing | test_models.py batch-smoke-tests any gateway model with tiny max_tokens |
| 🔁 Refresh testing | --refresh-test validates token rotation for an existing account |
| ✅ Connection verification | --verify checks a provider connection ID end-to-end |
Farming services such as 9Router aggregate free LLM provider accounts (FreeBuff, Blackbox, Kiro, QwenCloud…) behind an OpenAI-compatible API. The value is supplier diversity: when one provider rate-limits or dies, others keep the gateway healthy.
The blocker is registration friction — AWS Builder ID requires a real browser session, device-code consent, and OTP verification. This pipeline removes that friction:
- No manual browser work: camofox does anti-bot-detection navigation so signups are not throttled by Cloudflare-style defenses.
- No manual token handling: device-code → polling → refresh-rotation is fully scripted.
- No manual SQL: provider rows are inserted with the exact
providerSpecificDatashape 9Router expects.
┌─────────────┐ ┌───────────────────────┐ ┌─────────────────────────┐
│ camofox │ │ kiro_generator.py │ │ cloudmail_client.py │
│ (browser) │◄──►│ (orchestrator) │◄──►│ (temp-mail API) │
│ :9377 │ │ ─ OIDC device flow │ │ 4 CF domains │
└─────────────┘ │ ─ AWS token polling │ └─────────────────────────┘
│ ─ state persistence │
└──────────┬────────────┘
│ providerConnections INSERT
▼
┌───────────────────────┐
│ 9Router (SQLite) │
│ :20128 /v1/models │
└───────────────────────┘
Data flow, step by step:
gen_password()/extract_email_from_jwt()prepare credentials for the signup.register_client()→ POST to AWS OIDC client-registration endpoint →client_id+client_secret.device_authorization()→urn:ietf:params:oauth:grant-type:device_codegrant → user code.camofox_open()/camofox_type()/camofox_click()drive the consent UI.poll_token()polls the token endpoint until the user approves (intervalbackoff,max_attemptscap).insert_9router_connection()writes the provider row withproviderSpecificData.verify_connection()confirms the row is live in the gateway.
| Dependency | Version / Endpoint | Purpose |
|---|---|---|
| Python | 3.10+ | Runtime |
| camofox-browser | localhost:9377 |
Anti-bot-detection Chromium automation |
| 9Router | localhost:20128 |
LLM gateway (OpenAI-compatible) |
cloudmail_client.py |
on PYTHONPATH |
Cloudflare temp-mail API client |
Both camofox and 9Router are assumed to be already running on their default ports. The generator talks to them over HTTP only.
# 1. Clone
git clone https://github.com/apissaj/kiro-generator.git
cd kiro-generator
# 2. (Optional) isolated venv
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
# 3. Point PYTHONPATH at the temp-mail client
export PYTHONPATH=/path/to/cloudmail:$PYTHONPATH # Windows: set PYTHONPATH=C:\path\to\cloudmail
# 4. Verify both services respond
curl -s http://localhost:9377/healthz # camofox
curl -s http://localhost:20128/v1/models # 9Router (needs API key)No third-party Python packages are required — the pipeline uses only the standard
library (urllib, sqlite3, json, uuid, base64, …). The auxiliary registration
scripts (kiro-custom-register.py, pipeline-kiro-full.py) use playwright +
playwright-stealth instead of camofox; install those only if you use them:
pip install playwright playwright-stealth# Create 1 account (default)
python kiro_generator.py
# Create 5 accounts in a batch
python kiro_generator.py --batch 5
# Resume from the last persisted state
python kiro_generator.py --resume
# Verify a provider connection by ID
python kiro_generator.py --verify <connection_id>
# Test refresh-token rotation for an existing account (by email)
python kiro_generator.py --refresh-test someone@gmail.com
# Smoke-test models through the 9Router gateway
python test_models.py GM/gemini-3.6-flash ML/deepseek-v4-flash| Flag | Type | Default | Description |
|---|---|---|---|
--batch N |
int | 1 |
Number of accounts to provision in this run |
--resume |
flag | off | Continue from the last persisted batch state |
--verify ID |
str | — | Verify a 9Router provider connection ID |
--refresh-test EMAIL |
str | — | Test OIDC refresh rotation for an existing account |
| Argument | Description |
|---|---|
model... (1+) |
Model IDs to probe (e.g. GM/gemini-3.6-flash) |
Uses the first active API key in the 9Router database (%APPDATA%/9router/db/data.sqlite),
sends a minimal chat completion (max_tokens=15, stream=false) and prints status,
latency, error, and a content snippet per model. Zero-cost by design.
Creates a fresh inbox through cloudmail_client.make_inbox() from one of the 4 active
Cloudflare domains; generates a strong random password via gen_password().
Registers a confidential client against the AWS codebuild SSO endpoint. The returned
client_id / client_secret are stored per-account for token refresh.
Starts the OAuth device flow (urn:ietf:params:oauth:grant-type:device_code). A short
user code + verification URI are returned; the code is handed to the browser session.
Opens the verification URI in a camofox tab, then walks the form with snapshot-ref based
typing/clicking: email → display name → OTP (delivered to the temp inbox) → password →
confirm → Allow. The find_ref() helper locates form fields from the accessibility
snapshot, so selectors never break on minor DOM changes.
Polls the token endpoint every interval seconds (max max_attempts). On success, saves
the account record (email, clientId, clientSecret, accessToken, refreshToken,
expiresIn) to accounts/kiro/<email>.json.
Writes a providerConnections row with full providerSpecificData so the gateway can
refresh tokens itself and expose the account's models under /v1/models.
Each new account is inserted with a complete providerSpecificData payload:
{
"authMethod": "external_idp",
"region": "us-east-1",
"clientId": "<client_id>",
"clientSecret": "<client_secret>",
"tokenEndpoint": "https://default.region-1.sso.awscodebuild.amazonaws.com/token",
"scope": "codewhisperer:completions"
}After insertion, models appear in the gateway:
curl -s http://localhost:20128/v1/models | jq '.data[].id' | grep '^"kr/'kr/claude-opus-5 kr/claude-sonnet-4.5 kr/claude-haiku-4.5
kr/deepseek-3.2 kr/qwen3-coder-next kr/glm-5
kr/MiniMax-M2.5 kr/gpt-5.6-sol kr/gpt-5.6-terra
kr/gpt-5.6-luna + thinking/agentic variants (44 total)
⚠️ Known limitation: chat calls against these models currently fail with400 {"message":"profileArn is required for this request."}because free AWS Builder ID accounts do not expose aprofileArn(confirmed viaListAvailableProfiles→ 403 and Kiro-Go's ownisBuilderIDProfileUnsupportedErrorguard). The pipeline still provisions accounts correctly and remains the canonical reference for Builder ID OIDC + 9Router provider insertion.
kiro-generator/
├── kiro_generator.py # Main pipeline: register → token → 9Router insert
├── kiro-custom-register.py # Standalone Playwright-stealth registration (no camofox)
├── pipeline-kiro-full.py # Register + auto-upgrade loop variant
├── test_models.py # Gateway model smoke-test helper
├── test_kiro_eventstream.py # AWS EventStream encoder debug tool (Kiro runtime)
├── accounts/kiro/ # Per-account state (git-ignored, contains tokens)
├── .gitignore # Anti-secret ignore rules (+ .example exceptions)
├── LICENSE # MIT
└── README.md # This document
| Symptom | Likely cause | Fix |
|---|---|---|
400 REQUEST_BODY_INVALID on eventstream test |
Wrong protocol/content-type for Kiro runtime | Use JSON body for OAuth; see test_kiro_eventstream.py |
profileArn is required for this request. |
Free AWS Builder ID account has no profileArn | Not fixable per-account; provision accounts with qualifying AWS identity |
Connection refused: :9377 |
camofox not running | Start camofox server first |
Connection refused: :20128 |
9Router not running | Start 9Router gateway first |
ModuleNotFoundError: cloudmail_client |
PYTHONPATH not set | export PYTHONPATH=/path/to/cloudmail |
| Account exists but model 404 in gateway | Stale DB row | Re-run with --refresh-test to rotate tokens, then --verify |
- Never commit account state.
accounts/,token_test.json,device_auth_state.json,kiro_state.jsonare all git-ignored. The.gitignorekeeps.exampletemplates tracked while ignoring the real ones. - Tokens are treated as credentials.
accessTokenandrefreshTokengive API access — rotate immediately if ever exposed. - Scope of automation. This tool provisions accounts for your own use. Respect each service's Terms of Service and rate limits; do not resell or abuse.
- Local-only by default. The pipeline talks only to localhost services; no telemetry, no callbacks, no external logs.
- Support
profileArn-capable account provisioning (AWS IAM Identity Center / org accounts) - Automatic fallback: when
runtime.kiro.devaccepts eventstream chat, add a native Kiro runtime client - Multi-provider dry-run mode (
--dry-runshows planned insert without touching DB) - Docker-compose for camofox + 9Router + generator
- GitHub Actions smoke test that runs
test_models.pyagainst a mock gateway
Contributions are welcome. Please:
- Fork the repository and open a PR against
main. - Keep the core pipeline standard-library only (
urllib,sqlite3,json). - Never commit or paste real tokens/credentials in issues, PRs, or code.
- Conventional commit messages (
feat:,fix:,docs:,refactor:). - If you add a browser-automation path, prefer camofox over raw Playwright.
This project is provided as-is for educational and personal-automation purposes. The maintainers are not responsible for account bans, ToS violations, or any misuse. Check the terms of every service you automate, and stop if a service asks you to stop.
MIT © 2026 Hafizh Muzani