No description
  • Go 92%
  • JavaScript 3.5%
  • CSS 2.2%
  • HTML 2.1%
  • Dockerfile 0.2%
Find a file
Linyan Li a50dbf6389
Merge pull request #1 from a507588645/copilot/add-account-export-function
Add account export to importable JSON format
2026-03-18 19:46:09 +08:00
.github/workflows Initial commit: kiro2api project 2026-01-13 17:21:06 +08:00
auth feat: add account export functionality compatible with import format 2026-03-18 11:38:34 +00:00
config Add 4.6 models, adaptive thinking & region URLs 2026-02-18 17:17:20 +08:00
converter Handle assistant history, tool args, and clipboard 2026-03-13 19:22:24 +08:00
logger Initial commit: kiro2api project 2026-01-13 17:21:06 +08:00
parser Handle assistant history, tool args, and clipboard 2026-03-13 19:22:24 +08:00
server feat: add account export functionality compatible with import format 2026-03-18 11:38:34 +00:00
static feat: add account export functionality compatible with import format 2026-03-18 11:38:34 +00:00
types Add 4.6 models, adaptive thinking & region URLs 2026-02-18 17:17:20 +08:00
utils Remove legacy templates and Dockerfiles, update README 2026-01-23 19:02:23 +08:00
.dockerignore Initial commit: kiro2api project 2026-01-13 17:21:06 +08:00
.env.example Add model access control and model resolver 2026-02-18 09:51:10 +08:00
.gitignore Initial commit: kiro2api project 2026-01-13 17:21:06 +08:00
auth_config.json.example Initial commit: kiro2api project 2026-01-13 17:21:06 +08:00
Dockerfile Handle assistant history, tool args, and clipboard 2026-03-13 19:22:24 +08:00
go.mod Bump Go to 1.24 for build 2026-01-13 18:11:53 +08:00
go.sum Initial commit: kiro2api project 2026-01-13 17:21:06 +08:00
main.go Initial commit: kiro2api project 2026-01-13 17:21:06 +08:00
README.md Update README.md 2026-02-07 17:01:08 +08:00

Kiro2API

将 Anthropic/OpenAI API 请求转换为 Kiro/AWS CodeWhisperer API 的代理服务支持流式响应、工具调用、OAuth 授权与多账号轮换。


快速开始

方式一:源码运行

git clone https://github.com/a507588645/kiro2api.git
cd kiro2api
go build -o kiro2api main.go
./kiro2api

方式二Docker

docker build -t kiro2api .
docker run -p 8080:8080 --env-file .env kiro2api

基础配置(按你的环境变量重写)

.env 中填写(以下即你的配置):

KIRO_CLIENT_TOKEN=密码
SESSION_POOL_MAX_SIZE=3
SESSION_POOL_MAX_RETRIES=5
LOG_LEVEL=DEBUG
SESSION_POOL_COOLDOWN=60s
SESSION_POOL_ENABLED=true
OAUTH_ENABLED=true
OAUTH_TOKEN_FILE=/app/data/oauth_tokens.json
KIRO_UI_PASSWORD=登陆密码

注意:仍需提供上游认证配置 KIRO_AUTH_TOKENJSON 字符串或文件路径),否则无法正常获取凭证。

示例:

# JSON 方式
KIRO_AUTH_TOKEN='[{"auth":"Social","refreshToken":"your_refresh_token"}]'

# 或文件路径
KIRO_AUTH_TOKEN=./auth_config.json

Web 管理界面

  • 访问:http://localhost:8080/
  • 如果设置了 KIRO_UI_PASSWORD,将启用 Basic Auth 保护 //static/api/oauth

API 端点

Anthropic 兼容

  • POST /v1/messages
  • POST /v1/messages/count_tokens
  • GET /v1/models

OpenAI 兼容

  • POST /v1/chat/completions

OAuth 与账号导入

启用 OAUTH_ENABLED=true 后,可访问:

  • GET /oauthOAuth 授权页面
  • POST /api/import-accounts:导入账号 JSON

机器码管理UI

Dashboard 支持为账号绑定机器码UUID 或 64 位 HEX并在请求时自动使用绑定值。


License

MIT