CoolFace
Apppublic

windowsdalyzhou/ki2api

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
App README

Ki2API - Claude Sonnet 4 OpenAI Compatible API

OpenAI-compatible API for Claude Sonnet 4 via AWS CodeWhisperer. This service provides streaming support, tool calls, and multiple model access through a familiar OpenAI API interface.

Features

  • โ€”๐Ÿ”„ Streaming Support: Real-time response streaming
  • โ€”๐Ÿ› ๏ธ Tool Calls: Function calling capabilities
  • โ€”๐ŸŽฏ Multiple Models: Support for Claude Sonnet 4 and Claude 3.5 Haiku
  • โ€”๐Ÿ”ง XML Tool Parsing: Advanced tool call parsing
  • โ€”๐Ÿ”„ Auto Token Refresh: Automatic authentication token management
  • โ€”๐Ÿ›ก๏ธ Null Content Handling: Robust message processing
  • โ€”๐Ÿ” Tool Call Deduplication: Prevents duplicate function calls

API Endpoints

  • โ€”GET /v1/models - List available models
  • โ€”POST /v1/chat/completions - Create chat completions
  • โ€”GET /health - Health check
  • โ€”GET / - Service information

Environment Variables

Required environment variables:

  • โ€”API_KEY - Bearer token for API authentication (default: ki2api-key-2024)
  • โ€”KIRO_ACCESS_TOKEN - Kiro access token
  • โ€”KIRO_REFRESH_TOKEN - Kiro refresh token

Usage

bash
curl -X POST https://your-space-url/v1/chat/completions \n  -H "Authorization: Bearer ki2api-key-2024" \n  -H "Content-Type: application/json" \n  -d '{
    "model": "claude-sonnet-4-20250514",
    "messages": [
      {"role": "user", "content": "Hello!"}
    ]
  }'

Supported Models

  • โ€”claude-sonnet-4-20250514 - Claude Sonnet 4 (Latest)
  • โ€”claude-3-5-haiku-20241022 - Claude 3.5 Haiku

Built with FastAPI and optimized for Hugging Face Spaces deployment.