Skip to content

feat: add modern Claude model mappings + BIND_HOST/DISABLE_AUTH for gateway deployments#39

Open
vahnxu wants to merge 3 commits into
caidaoli:mainfrom
vahnxu:feat/add-opus-4.6-sonnet-4.6-haiku-4.5-mapping
Open

feat: add modern Claude model mappings + BIND_HOST/DISABLE_AUTH for gateway deployments#39
vahnxu wants to merge 3 commits into
caidaoli:mainfrom
vahnxu:feat/add-opus-4.6-sonnet-4.6-haiku-4.5-mapping

Conversation

@vahnxu

@vahnxu vahnxu commented Apr 17, 2026

Copy link
Copy Markdown

Summary

Three related improvements to make kiro2api usable with modern Claude models (Opus 4.5/4.6, Sonnet 4.6, Haiku 4.5) and easier to deploy behind upstream LLM gateways.

Kiro Pro already supports all current Claude models — verified via kiro-cli chat --list-models:

claude-opus-4.6   (1M ctx, rate 2.2)
claude-sonnet-4.6 (1M ctx, rate 1.3)
claude-opus-4.5   (200K ctx, rate 2.2)
claude-sonnet-4.5 (200K ctx, rate 1.3)
claude-haiku-4.5  (200K ctx, rate 0.4)

but kiro2api's ModelMap in config/config.go lists only Sonnet-4/4.5, 3.7-sonnet, 3.5-haiku plus a partial auto fallback for Haiku 4.5. Requests for Opus 4.6 etc. currently return "model not found".

Commits

  1. chore(deps): upgrade sonic to v1.15.0 for Go 1.26 compatibility
    Same fix as upgrade sonic to v1.15.0 for go1.26 build #37 (isabst) — sonic v1.14.1 fails to build on Go 1.26.x due to missing GoMapIterator. Included here to keep the branch self-contained (CI on Go 1.26 fails otherwise). Happy to drop if upgrade sonic to v1.15.0 for go1.26 build #37 lands first.

  2. feat(models): add Opus 4.5/4.6, Sonnet 4.6, Haiku 4.5 mappings
    Map the new aliases + date-suffixed variants to the kiro-cli model IDs that CodeWhisperer already accepts (e.g. claude-opus-4.6). TestModelMap_MappingsAreCorrectFormat relaxed to accept three value formats: CLAUDE_XXX_V1_0, claude-xxx-N.M, and auto. Added dedicated tests for the new aliases.

  3. feat(server): add BIND_HOST and DISABLE_AUTH for gateway deployments
    Two deployment conveniences when kiro2api runs behind an upstream gateway (Sub2API / OneAPI / LiteLLM / etc.):

    • BIND_HOST — restrict listen address (default: all interfaces; set 127.0.0.1 for gateway-behind hardening).
    • DISABLE_AUTH — skip kiro2api's own /v1 auth middleware (useful when the upstream gateway authenticates callers and transparently forwards their api-key, which won't match KIRO_CLIENT_TOKEN). Prints a warning at startup so operators don't accidentally expose the server without auth.
      Both default to existing behavior — existing deployments unaffected.

Validation

End-to-end with a real Kiro Pro (IdC) account on macOS + Linux VPS:

  • Non-streaming claude-opus-4-6: PASS (Anthropic response schema correct, usage tokens populated)
  • Streaming claude-sonnet-4-6: PASS (full Anthropic SSE event chain: message_startpingcontent_block_startcontent_block_delta × N → content_block_stopmessage_deltamessage_stop)
  • Non-streaming claude-haiku-4-5: PASS
  • go test ./... all green on Go 1.26.1

Test plan

  • go test ./config/... covers new ModelMap entries and format validator
  • go test ./server/... exercises middleware paths
  • Manual smoke via curl -X POST $BASE/v1/messages -d '{"model":"claude-opus-4-6",...}' with a real IdC account

🤖 Generated with Claude Code

vahnxu added 3 commits April 17, 2026 11:27
Go 1.26.x build fails with sonic v1.14.1 due to missing GoMapIterator
type. Upgrading to v1.15.0 restores build compatibility on modern Go
toolchains. Same fix as PR caidaoli#37 (isabst).

Verified with go 1.26.1 darwin/arm64 and linux/amd64.
Kiro Pro subscription already supports these models (verified via
'kiro-cli chat --list-models'), but kiro2api's ModelMap was missing
the entries, causing 'model not found' errors for modern Claude models.

Changes:
- Add claude-opus-4.5, claude-opus-4.5-20251101 → claude-opus-4.5
- Add claude-opus-4.6, claude-opus-4.6-20260205 → claude-opus-4.6
- Add claude-sonnet-4.6, claude-sonnet-4.6-20260205 → claude-sonnet-4.6
- Upgrade claude-haiku-4.5-20251001 from 'auto' to exact mapping
- Add claude-haiku-4.5 short alias

Value format follows kiro-cli's short ID (e.g. 'claude-opus-4.6'),
which CodeWhisperer accepts alongside the legacy CLAUDE_XXX_V1_0 format.
Relaxed test format validator to allow all three formats.

Validated end-to-end with real Kiro Pro account:
- Non-streaming opus-4.6: PASS
- Streaming sonnet-4.6: PASS (full Anthropic SSE event chain)
- Non-streaming haiku-4.5: PASS
When kiro2api runs behind an upstream LLM gateway (Sub2API, OneAPI, LiteLLM,
etc.), two deployment conveniences are common needs:

1. BIND_HOST — restrict the listening address. Default is all interfaces
   (':<port>'). Set 'BIND_HOST=127.0.0.1' to only accept connections
   from the same host (production hardening when behind a gateway).

2. DISABLE_AUTH — skip kiro2api's own API-key middleware on /v1/*. Useful
   when the upstream gateway already authenticates callers and transparently
   forwards their api-key header (which won't match KIRO_CLIENT_TOKEN).
   Emits a warning at startup so operators don't accidentally expose the
   server without auth.

Both features default to the previous behavior (listen on all interfaces,
require KIRO_CLIENT_TOKEN) so existing deployments are unaffected.

Example gateway-behind deployment .env:
  BIND_HOST=127.0.0.1
  PORT=8081
  DISABLE_AUTH=true
  KIRO_AUTH_TOKEN='[{"auth":"IdC","refreshToken":"...","clientId":"...","clientSecret":"..."}]'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant