Convert Kiro IDE's AI capabilities into standard API service, supporting both Claude and OpenAI API formats.
- Dual API Format: Support both Claude (
/v1/messages) and OpenAI (/v1/chat/completions) API formats - Multi-Account Pool: Manage multiple Kiro accounts with load balancing and failover
- Token Auto-Refresh: Automatic token refresh for both IDC and Social authentication
- Stream Support: Full streaming support with SSE
- Tool Calling: Complete function/tool calling support
- Admin Dashboard: Web-based management interface
- Rate Limiting: Per-key rate limiting and quota management
- Go 1.22+
- MySQL 8.0+
- Redis 6+
- Node.js 18+ (for frontend)
# Clone the repository
git clone https://github.com/yourname/apiro.git
cd apiro
# Start all services
docker-compose -f deployments/docker-compose.yml up -d
# Check logs
docker-compose -f deployments/docker-compose.yml logs -fAccess:
- API: http://localhost:3000
- Admin Dashboard: http://localhost:80
# Install Go dependencies
go mod download
# Install frontend dependencies
cd web && npm install && cd ..
# Install development tools
make install-tools# Copy example config
cp configs/config.example.yaml configs/config.yaml
# Edit config.yaml with your settings# Create database
mysql -u root -p -e "CREATE DATABASE apiro CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
# Run migrations
make migrate# Development mode (with hot reload)
make dev
# Or production mode
make build
./bin/apirocurl -X POST http://localhost:3000/v1/messages \
-H "Content-Type: application/json" \
-H "x-api-key: sk-your-api-key" \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": "claude-3-5-sonnet-20241022",
"max_tokens": 1024,
"messages": [
{"role": "user", "content": "Hello, Claude!"}
]
}'curl -X POST http://localhost:3000/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-your-api-key" \
-d '{
"model": "gpt-4",
"messages": [
{"role": "user", "content": "Hello!"}
]
}'Add "stream": true to enable streaming responses.
Configure Claude Code to use this service:
# Set environment variables
export ANTHROPIC_BASE_URL=http://localhost:3000/v1
export ANTHROPIC_API_KEY=sk-your-api-key
# Or in settings.json
{
"api": {
"baseUrl": "http://localhost:3000/v1",
"key": "sk-your-api-key"
}
}| Variable | Description | Default |
|---|---|---|
CONFIG_PATH |
Path to config file | ./configs/config.yaml |
SERVER_PORT |
Server port | 3000 |
DATABASE_MYSQL_HOST |
MySQL host | localhost |
DATABASE_MYSQL_PORT |
MySQL port | 3306 |
DATABASE_REDIS_HOST |
Redis host | localhost |
DATABASE_REDIS_PORT |
Redis port | 6379 |
server:
port: 3000
mode: release
database:
mysql:
host: localhost
port: 3306
user: root
password: password
database: apiro
redis:
host: localhost
port: 6379
kiro:
default_region: us-east-1
token_refresh_threshold: 600
admin:
username: admin
password: admin123apiro/
├── cmd/server/ # Application entry point
├── internal/
│ ├── app/ # Application initialization
│ ├── config/ # Configuration
│ ├── handler/ # HTTP handlers
│ ├── middleware/ # Middlewares
│ ├── model/ # Data models
│ ├── repository/ # Data access layer
│ ├── service/ # Business logic
│ ├── provider/kiro/ # Kiro API client
│ ├── pool/ # Account pool management
│ ├── router/ # Route registration
│ └── cron/ # Scheduled tasks
├── pkg/ # Shared packages
├── web/ # React frontend
├── configs/ # Configuration files
├── migrations/ # Database migrations
├── deployments/ # Docker files
└── scripts/ # Utility scripts
# Build
make build # Build binary
make build-prod # Build for production
# Development
make dev # Run with hot reload
make run # Run directly
make test # Run tests
make lint # Run linter
# Code Generation
make swagger # Generate Swagger docs
make wire # Generate Wire DI
# Database
make migrate # Run migrations
# Docker
make docker # Build backend image
make docker-frontend # Build frontend image
make up # Start with Docker Compose
make down # Stop Docker Compose
make logs # View logs
# Frontend
make web-install # Install dependencies
make web-dev # Run dev server
make web-build # Build for production
# Utility
make clean # Clean build artifacts
make install-tools # Install dev tools
make help # Show all commands| Endpoint | Method | Description |
|---|---|---|
/v1/messages |
POST | Claude Messages API |
/v1/chat/completions |
POST | OpenAI Chat Completions |
/v1/models |
GET | List available models |
/health |
GET | Health check |
/ready |
GET | Readiness check |
| Endpoint | Description |
|---|---|
/admin/login |
Admin login |
/admin/dashboard/* |
Dashboard statistics |
/admin/channels/* |
Account management |
/admin/tokens/* |
API key management |
/admin/users/* |
User management |
/admin/logs/* |
Request logs |
- Login to admin dashboard at http://localhost:80
- Navigate to "Channels" page
- Click "Add Channel"
- Fill in the required fields:
- Name: Display name
- Type: IDC (Builder ID) or Social (Google)
- Refresh Token: Your Kiro refresh token
- Client ID/Secret: For IDC type only
- Region: AWS region (e.g., us-east-1)
curl -X POST http://localhost:3000/admin/channels \
-H "Authorization: Bearer <admin_token>" \
-H "Content-Type: application/json" \
-d '{
"name": "Account 1",
"type": 1,
"refresh_token": "aorAxxxxxx",
"client_id": "e8pqSrALVjvb",
"client_secret": "eyJraWQiOi...",
"region": "us-east-1",
"weight": 1
}'All requests are proxied to Kiro's backend. The following model names are accepted and mapped to Kiro's default model:
| 模型 ID | 说明 |
|---|---|
claude-opus-4-5-20251101 |
最强模型,支持 effort 参数 |
claude-sonnet-4-5-20241022 |
推荐,性价比最优 |
claude-haiku-4-5-20241022 |
最快响应 |
| 模型 ID | 说明 |
|---|---|
claude-opus-4-20250514 |
Opus 4 基础版 |
claude-sonnet-4-20250514 |
Sonnet 4 基础版 |
| 模型 ID | 说明 |
|---|---|
claude-3-5-sonnet-20241022 |
Claude 3.5 Sonnet |
claude-3-opus-20240229 |
Claude 3 Opus |
claude-3-haiku-20240307 |
Claude 3 Haiku |
| 模型 ID | 说明 |
|---|---|
gpt-5 |
最新旗舰 (2025.8) |
gpt-5-mini |
GPT-5 轻量版 |
o3 |
推理模型,复杂任务 |
o4-mini |
快速推理模型 |
o1 |
推理模型 (旧版) |
o1-mini |
推理模型轻量版 (已弃用) |
gpt-4.1 |
非推理最强,100万上下文 |
gpt-4.1-mini |
GPT-4.1 轻量版 |
gpt-4.1-nano |
GPT-4.1 最小版 |
gpt-4o |
GPT-4 Omni |
gpt-4o-mini |
GPT-4o 轻量版 |
gpt-4-turbo |
Legacy |
gpt-4 |
Legacy |
gpt-3.5-turbo |
Legacy |
Note: 所有请求最终都由 Kiro 后端处理,模型名称主要用于 API 兼容性。
Check the channel's refresh token and credentials. You can manually trigger a refresh:
curl -X POST http://localhost:3000/admin/channels/1/refresh \
-H "Authorization: Bearer <admin_token>"Ensure at least one channel is enabled and healthy:
curl http://localhost:3000/readyCheck MySQL and Redis connectivity:
# In container
docker exec -it apiro-api /app/apiro --healthMIT License