Commit e1ac419c authored by Your Name's avatar Your Name

Remove external kiro-gateway integration documentation

- Deleted KIRO_GATEWAY.md and KIRO_INTEGRATION.md
- AISBF has native Kiro support built-in via KiroProviderHandler
- No need for external kiro-gateway integration documentation
parent 0d684270
......@@ -367,7 +367,7 @@ Settings can be specified at three levels with the following priority:
### Kiro Gateway Integration
**Overview:**
Kiro Gateway is a third-party proxy gateway that provides OpenAI and Anthropic-compatible APIs for Kiro (Amazon Q Developer / AWS CodeWhisperer). It's located in the `vendor/kiro-gateway` directory and has been integrated as a provider type in AISBF.
Kiro Gateway is a third-party proxy gateway that provides OpenAI and Anthropic-compatible APIs for Kiro (Amazon Q Developer / AWS CodeWhisperer). It's available as a separate GitHub project and has been integrated as a provider type in AISBF.
**What is Kiro Gateway:**
- Proxy gateway for accessing Claude models through Kiro IDE/CLI credentials
......
# Kiro Gateway Integration Guide
This guide explains how to use kiro-gateway with AISBF to access Claude models through Kiro (Amazon Q Developer / AWS CodeWhisperer) credentials.
## Table of Contents
- [Overview](#overview)
- [What is Kiro Gateway?](#what-is-kiro-gateway)
- [Prerequisites](#prerequisites)
- [Setup Instructions](#setup-instructions)
- [Step 1: Install Kiro Gateway](#step-1-install-kiro-gateway)
- [Step 2: Configure Kiro Gateway](#step-2-configure-kiro-gateway)
- [Step 3: Start Kiro Gateway](#step-3-start-kiro-gateway)
- [Step 4: Configure AISBF](#step-4-configure-aisbf)
- [Usage Examples](#usage-examples)
- [Available Models](#available-models)
- [Troubleshooting](#troubleshooting)
- [Architecture](#architecture)
## Overview
Kiro Gateway is a proxy gateway that provides OpenAI and Anthropic-compatible APIs for accessing Claude models through Kiro credentials. By integrating it with AISBF, you can:
- Access Claude models using Kiro IDE or kiro-cli credentials
- Use Claude models in AISBF rotations alongside other providers
- Benefit from automatic failover and load balancing
- Leverage Kiro's free tier or paid plans without direct Anthropic API access
## What is Kiro Gateway?
Kiro Gateway is a standalone FastAPI application that:
- Proxies requests to Kiro's backend API
- Provides OpenAI-compatible endpoints (`/v1/chat/completions`, `/v1/models`)
- Provides Anthropic-compatible endpoints (`/v1/messages`)
- Supports both Kiro IDE and kiro-cli authentication methods
- Includes features like extended thinking, tool calling, and streaming
Kiro Gateway is maintained as a separate project. You can find it at: https://github.com/jwadow/kiro-gateway
## Prerequisites
Before setting up kiro-gateway with AISBF, ensure you have:
1. **Kiro Credentials**: Either Kiro IDE or kiro-cli configured and authenticated
2. **Python 3.10+**: Required for running kiro-gateway
3. **AISBF Installed**: AISBF should be installed and configured
4. **Network Access**: Both services should be able to communicate (typically on localhost)
## Setup Instructions
### Step 1: Install Kiro Gateway
Clone and install kiro-gateway from GitHub:
```bash
# Clone the kiro-gateway repository
git clone https://github.com/jwadow/kiro-gateway.git
cd kiro-gateway
# Install dependencies
pip install -r requirements.txt
```
### Step 2: Configure Kiro Gateway
1. Create a `.env` file with your configuration:
```bash
# Authentication method (choose one)
KIRO_AUTH_METHOD=ide # or 'cli'
# For IDE authentication
KIRO_IDE_CONFIG_PATH=~/.config/Code/User/globalStorage/amazon.q/credentials.json
# For CLI authentication
KIRO_CLI_PATH=/path/to/kiro-cli
# API Key for securing the proxy
PROXY_API_KEY=your-secure-api-key-here
# Optional: Server configuration
HOST=127.0.0.1
PORT=8000
LOG_LEVEL=INFO
```
2. **Important**: Choose your authentication method:
**Option A: Kiro IDE Authentication**
- Set `KIRO_AUTH_METHOD=ide`
- Set `KIRO_IDE_CONFIG_PATH` to your Kiro IDE credentials location
- Typical location: `~/.config/Code/User/globalStorage/amazon.q/credentials.json`
**Option B: kiro-cli Authentication**
- Set `KIRO_AUTH_METHOD=cli`
- Set `KIRO_CLI_PATH` to your kiro-cli executable
- Ensure kiro-cli is authenticated: `kiro-cli auth login`
### Step 3: Start Kiro Gateway
Start the kiro-gateway server:
```bash
python main.py
```
You should see output indicating the server is running:
```
INFO: Started server process
INFO: Waiting for application startup.
INFO: Application startup complete.
Uvicorn running on http://127.0.0.1:8000
```
**Tip**: Run kiro-gateway in a separate terminal or as a background service to keep it running while using AISBF.
### Step 4: Configure AISBF
1. **Add Kiro Provider to `~/.aisbf/providers.json`**:
```json
{
"kiro": {
"id": "kiro",
"name": "Kiro Gateway (Amazon Q Developer)",
"endpoint": "http://localhost:8000/v1",
"type": "kiro",
"api_key_required": true,
"api_key": "YOUR_KIRO_GATEWAY_API_KEY",
"rate_limit": 0,
"models": [
{
"name": "claude-sonnet-4-5",
"rate_limit": 0,
"max_request_tokens": 200000,
"context_size": 200000
},
{
"name": "claude-haiku-4-5",
"rate_limit": 0,
"max_request_tokens": 200000,
"context_size": 200000
},
{
"name": "claude-opus-4-5",
"rate_limit": 0,
"max_request_tokens": 200000,
"context_size": 200000
},
{
"name": "claude-sonnet-4",
"rate_limit": 0,
"max_request_tokens": 200000,
"context_size": 200000
},
{
"name": "auto",
"rate_limit": 0,
"max_request_tokens": 200000,
"context_size": 200000
}
]
}
}
```
**Important**: Replace `YOUR_KIRO_GATEWAY_API_KEY` with the `PROXY_API_KEY` you set in kiro-gateway's `.env` file.
2. **Add Kiro Rotation to `~/.aisbf/rotations.json`** (optional):
```json
{
"kiro-claude": {
"model_name": "kiro-claude",
"providers": [
{
"provider_id": "kiro",
"models": [
{
"name": "claude-sonnet-4-5",
"weight": 3,
"rate_limit": 0
},
{
"name": "claude-haiku-4-5",
"weight": 1,
"rate_limit": 0
}
]
}
]
}
}
```
3. **Restart AISBF** to apply the configuration changes:
```bash
# If running as a daemon
aisbf restart
# If running manually
aisbf
```
## Usage Examples
### Direct Provider Access
Access kiro-gateway directly through AISBF:
```bash
curl -X POST http://localhost:17765/api/kiro/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-5",
"messages": [
{"role": "user", "content": "Hello, how are you?"}
]
}'
```
### Rotation Access
Use kiro-gateway through a rotation (with automatic model selection):
```bash
curl -X POST http://localhost:17765/api/kiro-claude/chat/completions \
-H "Content-Type: application/json" \
-d '{
"messages": [
{"role": "user", "content": "Explain quantum computing"}
]
}'
```
### Streaming Responses
Enable streaming for real-time responses:
```bash
curl -X POST http://localhost:17765/api/kiro/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-5",
"messages": [
{"role": "user", "content": "Write a short story"}
],
"stream": true
}'
```
### Tool Calling
Use Claude's tool calling capabilities:
```bash
curl -X POST http://localhost:17765/api/kiro/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-5",
"messages": [
{"role": "user", "content": "What is the weather in San Francisco?"}
],
"tools": [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the current weather",
"parameters": {
"type": "object",
"properties": {
"location": {"type": "string"}
}
}
}
}
]
}'
```
### List Available Models
Query available models through kiro-gateway:
```bash
curl http://localhost:17765/api/kiro/models
```
## Available Models
Kiro Gateway provides access to the following Claude models:
| Model ID | Description | Context Size | Best For |
|----------|-------------|--------------|----------|
| `claude-sonnet-4-5` | Enhanced Sonnet model | 200K tokens | Balanced performance and quality |
| `claude-haiku-4-5` | Fast Haiku model | 200K tokens | Quick responses, lower cost |
| `claude-opus-4-5` | Top-tier Opus model | 200K tokens | Complex tasks (may require paid tier) |
| `claude-sonnet-4` | Previous generation Sonnet | 200K tokens | Stable, proven performance |
| `auto` | Automatic model selection | Varies | Let Kiro choose the best model |
**Note**: Model availability depends on your Kiro subscription tier. Some models may require a paid plan.
## Troubleshooting
### Kiro Gateway Not Starting
**Problem**: Kiro Gateway fails to start or crashes immediately.
**Solutions**:
1. Check that all dependencies are installed: `pip install -r requirements.txt`
2. Verify your `.env` file has correct configuration
3. Ensure Kiro credentials are valid and authenticated
4. Check logs for specific error messages
### Authentication Errors
**Problem**: Getting 401 Unauthorized errors from kiro-gateway.
**Solutions**:
1. Verify `PROXY_API_KEY` in kiro-gateway's `.env` matches the API key in AISBF's configuration
2. For IDE auth: Check that `KIRO_IDE_CONFIG_PATH` points to a valid credentials file
3. For CLI auth: Run `kiro-cli auth status` to verify authentication
4. Try re-authenticating: `kiro-cli auth login`
### Connection Refused
**Problem**: AISBF cannot connect to kiro-gateway.
**Solutions**:
1. Verify kiro-gateway is running: `curl http://localhost:8000/health`
2. Check that the endpoint in AISBF's `providers.json` matches kiro-gateway's address
3. Ensure no firewall is blocking the connection
4. Verify the port (default 8000) is not in use by another service
### Model Not Available
**Problem**: Requested model returns an error or is not available.
**Solutions**:
1. Check your Kiro subscription tier - some models require paid plans
2. Use `auto` model to let Kiro select an available model
3. Try a different model (e.g., `claude-haiku-4-5` instead of `claude-opus-4-5`)
4. Check kiro-gateway logs for specific error messages
### Rate Limiting
**Problem**: Requests are being rate limited.
**Solutions**:
1. Check your Kiro account's rate limits
2. Adjust `rate_limit` values in AISBF's configuration
3. Use rotations to distribute load across multiple providers
4. Consider upgrading your Kiro subscription for higher limits
### Streaming Not Working
**Problem**: Streaming responses are not working correctly.
**Solutions**:
1. Ensure `stream: true` is set in the request
2. Check that your client supports Server-Sent Events (SSE)
3. Verify no proxy or middleware is buffering the response
4. Check kiro-gateway logs for streaming-related errors
## Architecture
### Integration Overview
```
┌─────────────┐ ┌─────────────┐ ┌──────────────┐
│ Client │ ──────> │ AISBF │ ──────> │ Kiro Gateway │
│ │ │ Proxy │ │ │
└─────────────┘ └─────────────┘ └──────────────┘
│ │
│ │
v v
┌─────────────┐ ┌──────────────┐
│ Rotations │ │ Kiro API │
│ Failover │ │ (Claude) │
└─────────────┘ └──────────────┘
```
### Request Flow
1. **Client Request**: Client sends request to AISBF endpoint
2. **AISBF Processing**: AISBF validates, routes, and applies rotation logic
3. **Provider Selection**: AISBF selects kiro provider based on configuration
4. **Kiro Gateway**: Request is forwarded to kiro-gateway
5. **Authentication**: Kiro Gateway authenticates using IDE or CLI credentials
6. **Kiro API**: Request is sent to Kiro's backend API
7. **Response**: Response flows back through the chain to the client
### Key Components
- **[`KiroProviderHandler`](aisbf/providers.py)**: Handler class in AISBF that manages kiro-gateway communication
- **OpenAI SDK**: Used to communicate with kiro-gateway's OpenAI-compatible endpoints
- **Kiro Gateway**: Standalone FastAPI proxy (external project)
- **Kiro Credentials**: IDE or CLI authentication for accessing Kiro API
### Benefits of This Architecture
1. **Clean Separation**: Kiro Gateway runs independently, no code duplication
2. **Easy Maintenance**: Update kiro-gateway without modifying AISBF
3. **Flexibility**: Use kiro-gateway with other tools or directly
4. **Standard Interface**: OpenAI-compatible API works with existing tools
5. **Rotation Support**: Combine with other providers for failover and load balancing
## Additional Resources
- [AISBF Documentation](DOCUMENTATION.md)
- [Kiro Gateway GitHub](https://github.com/jwadow/kiro-gateway)
- [AISBF AI.PROMPT](AI.PROMPT) - Contains integration details and configuration examples
## Support
For issues related to:
- **AISBF**: Check [DOCUMENTATION.md](DOCUMENTATION.md) and [DEBUG_GUIDE.md](DEBUG_GUIDE.md)
- **Kiro Gateway**: Check [Kiro Gateway GitHub](https://github.com/jwadow/kiro-gateway)
- **Kiro Credentials**: Refer to Amazon Q Developer / AWS CodeWhisperer documentation
---
**Last Updated**: 2026-03-23
# Kiro Integration for AISBF
## Overview
AISBF now includes **direct integration** with Kiro (Amazon Q Developer), allowing you to use Claude models through your Kiro IDE or kiro-cli credentials without running a separate kiro-gateway server.
This integration was built by analyzing and incorporating the core functionality from the [kiro-gateway](https://github.com/jwadow/kiro-gateway) project directly into AISBF.
## Features
- **Direct API Integration**: Makes API calls directly to Amazon Q Developer's API
- **Multiple Credential Sources**: Supports Kiro IDE, kiro-cli, and environment variables
- **Automatic Token Refresh**: Handles token expiration and refresh automatically
- **No External Dependencies**: No need to run kiro-gateway as a separate service
- **Multiple Authentication Types**: Supports both Kiro Desktop Auth and AWS SSO OIDC
## Architecture
The integration consists of three main components:
1. **`aisbf/kiro_auth.py`**: Authentication manager that handles:
- Loading credentials from multiple sources
- Token refresh for both Kiro Desktop Auth and AWS SSO OIDC
- Automatic token lifecycle management
2. **`aisbf/kiro_utils.py`**: Utility functions for:
- Machine fingerprint generation
- Model name normalization
- Request/response format conversion
3. **`aisbf/providers.py`**: KiroProviderHandler that:
- Uses KiroAuthManager for authentication
- Makes direct HTTP requests to Kiro's API
- Converts between OpenAI format and Kiro format
## Configuration
### Method 1: Using Kiro IDE Credentials (JSON File)
If you have Kiro IDE (VS Code extension) installed, AISBF can use its credentials directly.
**Location**: `~/.config/Code/User/globalStorage/amazon.q/credentials.json`
**Configuration in `~/.aisbf/providers.json`**:
```json
{
"providers": {
"kiro": {
"id": "kiro",
"name": "Kiro (Amazon Q Developer)",
"endpoint": "https://q.us-east-1.amazonaws.com",
"type": "kiro",
"api_key_required": false,
"rate_limit": 0,
"kiro_config": {
"creds_file": "~/.config/Code/User/globalStorage/amazon.q/credentials.json",
"region": "us-east-1"
}
}
}
}
```
### Method 2: Using kiro-cli Credentials (SQLite Database)
If you have kiro-cli installed, AISBF can use its credentials from the SQLite database.
**Location**: `~/.local/share/kiro-cli/data.sqlite3`
**Configuration in `~/.aisbf/providers.json`**:
```json
{
"providers": {
"kiro-cli": {
"id": "kiro-cli",
"name": "Kiro CLI (Amazon Q Developer)",
"endpoint": "https://q.us-east-1.amazonaws.com",
"type": "kiro",
"api_key_required": false,
"rate_limit": 0,
"kiro_config": {
"sqlite_db": "~/.local/share/kiro-cli/data.sqlite3",
"region": "us-east-1"
}
}
}
}
```
### Method 3: Using Environment Variables
You can also provide credentials directly via environment variables or configuration.
**Configuration in `~/.aisbf/providers.json`**:
```json
{
"providers": {
"kiro": {
"id": "kiro",
"name": "Kiro (Amazon Q Developer)",
"endpoint": "https://q.us-east-1.amazonaws.com",
"type": "kiro",
"api_key_required": false,
"rate_limit": 0,
"kiro_config": {
"refresh_token": "your-refresh-token-here",
"profile_arn": "arn:aws:codewhisperer:us-east-1:...",
"client_id": "your-client-id",
"client_secret": "your-client-secret",
"region": "us-east-1"
}
}
}
}
```
## Available Models
The following Claude models are available through Kiro:
- `anthropic.claude-3-5-sonnet-20241022-v2:0` - Claude 3.5 Sonnet v2 (latest)
- `anthropic.claude-3-5-haiku-20241022-v1:0` - Claude 3.5 Haiku
- `anthropic.claude-3-5-sonnet-20240620-v1:0` - Claude 3.5 Sonnet v1
- `anthropic.claude-sonnet-3-5-v2` - Claude 3.5 Sonnet v2 (alias)
## Usage Examples
### Using Kiro Provider Directly
```bash
# Using Kiro provider with a specific model
curl -X POST http://localhost:8080/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"provider_id": "kiro",
"model": "anthropic.claude-3-5-sonnet-20241022-v2:0",
"messages": [
{"role": "user", "content": "Hello, how are you?"}
]
}'
```
### Using Kiro in a Rotation
Add Kiro to your rotation configuration in `~/.aisbf/rotations.json`:
```json
{
"rotations": {
"kiro-claude": {
"providers": [
{
"provider_id": "kiro",
"model": "anthropic.claude-3-5-sonnet-20241022-v2:0",
"weight": 1
},
{
"provider_id": "kiro-cli",
"model": "anthropic.claude-3-5-sonnet-20241022-v2:0",
"weight": 1
}
],
"notifyerrors": true
}
}
}
```
Then use the rotation:
```bash
curl -X POST http://localhost:8080/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"rotation_id": "kiro-claude",
"messages": [
{"role": "user", "content": "Hello, how are you?"}
]
}'
```
## Authentication Types
### Kiro Desktop Auth
Used by Kiro IDE (VS Code extension). Credentials are stored in JSON format.
- **Token URL**: `https://prod.{region}.auth.desktop.kiro.dev/refreshToken`
- **Method**: POST with JSON body containing refresh token
- **Response**: Access token with expiration time
### AWS SSO OIDC
Used by kiro-cli. Credentials are stored in SQLite database.
- **Token URL**: `https://oidc.{region}.amazonaws.com/token`
- **Method**: POST with form data (grant_type, client_id, client_secret, refresh_token)
- **Response**: Access token with expiration time
## Regions
Kiro supports multiple AWS regions:
- `us-east-1` (default)
- `eu-central-1`
- `ap-southeast-1`
- `us-west-2`
The API endpoint is always `https://q.{region}.amazonaws.com`, regardless of the region.
## Troubleshooting
### "Kiro authentication not configured"
**Cause**: No valid credentials found in any of the configured sources.
**Solution**:
1. Verify that Kiro IDE or kiro-cli is installed and authenticated
2. Check that the credential file/database path is correct
3. Ensure the credentials haven't expired
### "Profile ARN not available"
**Cause**: The profile ARN couldn't be loaded from credentials.
**Solution**:
1. Re-authenticate with Kiro IDE or kiro-cli
2. Verify that your AWS account has access to Amazon Q Developer
3. Check that the credentials file contains a valid profile ARN
### Token Refresh Failures
**Cause**: Refresh token has expired or is invalid.
**Solution**:
1. Re-authenticate with Kiro IDE or kiro-cli
2. Check that your AWS credentials are still valid
3. Verify network connectivity to AWS endpoints
### "Improperly formed request"
**Cause**: The request format doesn't match Kiro API requirements.
**Solution**:
1. Check that you're using a valid model ID
2. Ensure messages are properly formatted
3. Review the logs for specific error details
## Logging
Enable debug logging to see detailed information about Kiro API calls:
```bash
export AISBF_DEBUG=true
python -m aisbf.main
```
This will show:
- Authentication attempts and token refresh
- API request/response details
- Credential loading process
- Error details
## Comparison with kiro-gateway
### Before (External kiro-gateway)
```
Client → AISBF → kiro-gateway (separate process) → Kiro API
```
**Drawbacks**:
- Need to run kiro-gateway as a separate service
- Additional network hop
- More complex deployment
### After (Direct Integration)
```
Client → AISBF → Kiro API
```
**Benefits**:
- No external dependencies
- Simpler deployment
- Lower latency
- Unified configuration
## Credits
This integration was built by analyzing and incorporating functionality from:
- [kiro-gateway](https://github.com/jwadow/kiro-gateway) by Jwadow
The core authentication and API interaction logic was adapted from kiro-gateway's implementation.
## License
The Kiro integration code in AISBF is licensed under the GNU General Public License v3.0, consistent with AISBF's license.
The original kiro-gateway project is licensed under the GNU Affero General Public License v3.0.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment