Spaces:
Sleeping
Sleeping
| #!/usr/bin/env python3 | |
| """ | |
| Run Kiro LLM API Server | |
| Usage: | |
| python -m autoreg.llm.run_llm_server | |
| python autoreg/llm/run_llm_server.py | |
| Environment variables: | |
| KIRO_LLM_PORT - Server port (default: 8421) | |
| KIRO_LLM_HOST - Server host (default: 0.0.0.0) | |
| KIRO_LLM_API_KEY - Optional API key for authentication | |
| """ | |
| import os | |
| import sys | |
| from pathlib import Path | |
| # Add parent directories to path | |
| sys.path.insert(0, str(Path(__file__).parent.parent.parent)) | |
| sys.path.insert(0, str(Path(__file__).parent.parent)) | |
| def main(): | |
| import uvicorn | |
| from autoreg.llm.llm_server import app | |
| port = int(os.environ.get("KIRO_LLM_PORT", 8421)) | |
| host = os.environ.get("KIRO_LLM_HOST", "0.0.0.0") | |
| print(f""" | |
| ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| β Kiro LLM API Server β | |
| β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ£ | |
| β OpenAI-compatible API using Kiro tokens β | |
| β β | |
| β Endpoints: β | |
| β GET /v1/models - List models β | |
| β POST /v1/chat/completions - Chat (streaming supported) β | |
| β GET /health - Health check β | |
| β GET /pool/status - Token pool status β | |
| β β | |
| β Usage with OpenAI client: β | |
| β client = OpenAI( β | |
| β base_url="http://localhost:{port}/v1", β | |
| β api_key="any" β | |
| β ) β | |
| ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| """.format(port=port)) | |
| uvicorn.run( | |
| app, | |
| host=host, | |
| port=port, | |
| log_level="info" | |
| ) | |
| if __name__ == "__main__": | |
| main() | |