{"id":51011148,"url":"https://github.com/longcipher/aihub","last_synced_at":"2026-06-21T02:32:10.986Z","repository":{"id":366113141,"uuid":"1271129169","full_name":"longcipher/aihub","owner":"longcipher","description":null,"archived":false,"fork":false,"pushed_at":"2026-06-20T09:00:19.000Z","size":99,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-06-20T11:04:19.464Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/longcipher.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2026-06-16T11:09:58.000Z","updated_at":"2026-06-20T09:00:23.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/longcipher/aihub","commit_stats":null,"previous_names":["longcipher/aihub"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/longcipher/aihub","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/longcipher%2Faihub","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/longcipher%2Faihub/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/longcipher%2Faihub/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/longcipher%2Faihub/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/longcipher","download_url":"https://codeload.github.com/longcipher/aihub/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/longcipher%2Faihub/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34592050,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-21T02:00:05.568Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-21T02:32:10.881Z","updated_at":"2026-06-21T02:32:10.981Z","avatar_url":"https://github.com/longcipher.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AiHub - High-Performance LLM Gateway\n\n\u003cp align=\"center\"\u003e\n  \u003cp align=\"center\"\u003eOpen-source, high-performance LLM gateway written in Rust. Connect to any LLM provider with a single API. Observability Included.\u003c/p\u003e\n\u003c/p\u003e\n\n## Features\n\n- **Multi-Provider Support**: 143+ LLM providers via liter-llm integration\n- **OpenAI Compatible API**: Drop-in replacement for OpenAI API calls\n- **Two Deployment Modes**:\n  - **YAML Mode**: Simple static configuration with config files\n  - **Database Mode**: Dynamic configuration with PostgreSQL and Management API\n- **Built-in Observability**: OpenTelemetry tracing and Prometheus metrics\n- **High Performance**: Written in Rust with async/await support\n- **Hot Reload**: Dynamic configuration updates (Database mode)\n- **Pipeline System**: Extensible request/response processing\n- **Workspace Architecture**: Modular design with `hub-core`, `hub-gateway`, `hub-management`\n\n## Quick Start\n\n### Using Cargo\n\n```bash\n# Clone and build\ngit clone https://github.com/longcipher/aihub.git\ncd aihub\ncargo build --release\n\n# YAML Mode\n./target/release/hub\n\n# Database Mode  \nHUB_MODE=database DATABASE_URL=postgresql://user:pass@host:5432/db ./target/release/hub\n```\n\n## Architecture\n\nThe project uses a Cargo workspace architecture:\n\n```\naihub/\n├── bin/hub/                    # Binary crate\n│   └── src/main.rs             # Application entry point\n├── crates/\n│   ├── hub-core/               # Core library\n│   │   ├── config/             # Configuration management\n│   │   ├── provider/           # LLM provider adapter\n│   │   ├── state.rs            # Application state management\n│   │   └── types/              # Shared type definitions\n│   ├── hub-gateway/            # Gateway library\n│   │   ├── routes.rs           # HTTP routing\n│   │   └── pipeline/           # Request processing pipelines\n│   └── hub-management/         # Management API library\n│       ├── api/                # REST API endpoints\n│       ├── db/                 # Database models and repositories\n│       ├── services/           # Business logic\n│       └── dto.rs              # Data transfer objects\n├── migrations/                 # Database migrations\n├── tests/                      # Integration tests\n└── config.yaml                 # Example configuration\n```\n\n## Configuration Modes\n\n### YAML Mode\n\nPerfect for simple deployments and development environments.\n\n**Features:**\n\n- Static configuration via `config.yaml`\n- No external dependencies\n- Simple provider and model setup\n- No management API\n- Single port (3000)\n\n**Example config.yaml:**\n\n```yaml\nproviders:\n  - key: openai\n    type: openai\n    api_key: sk-...\n\nmodels:\n  - key: gpt-4\n    type: gpt-4\n    provider: openai\n\npipelines:\n  - name: chat\n    type: Chat\n    plugins:\n      - ModelRouter:\n          models: [gpt-4]\n```\n\n### Database Mode\n\nIdeal for production environments requiring dynamic configuration.\n\n**Features:**\n\n- PostgreSQL-backed configuration\n- REST Management API (`/api/v1/management/*`)\n- Hot reload without restarts\n- Configuration polling and synchronization\n- Dual ports (3000 for Gateway, 8080 for Management)\n\n**Setup:**\n\n1. Set up PostgreSQL database\n2. Run migrations: `sqlx migrate run`\n3. Set environment variables:\n\n   ```bash\n   HUB_MODE=database\n   DATABASE_URL=postgresql://user:pass@host:5432/db\n   ```\n\n## API Endpoints\n\n### Core LLM Gateway (Both Modes)\n\n**Port 3000:**\n\n- `POST /api/v1/chat/completions` - Chat completions\n- `POST /api/v1/completions` - Text completions  \n- `POST /api/v1/embeddings` - Text embeddings\n- `GET /health` - Health check\n- `GET /metrics` - Prometheus metrics\n- `GET /swagger-ui` - OpenAPI documentation\n\n### Management API (Database Mode Only)\n\n**Port 8080:**\n\n- `GET /health` - Management API health check\n- `GET|POST|PUT|DELETE /api/v1/management/providers` - Provider management\n- `GET|POST|PUT|DELETE /api/v1/management/model-definitions` - Model management\n- `GET|POST|PUT|DELETE /api/v1/management/pipelines` - Pipeline management\n\n## Provider Configuration\n\n### OpenAI\n\n```yaml\nproviders:\n  - key: openai\n    type: openai\n    api_key: sk-...\n    # Optional\n    organization_id: org-...\n    base_url: https://api.openai.com/v1\n```\n\n### Anthropic\n\n```yaml\nproviders:\n  - key: anthropic\n    type: anthropic\n    api_key: sk-ant-...\n```\n\n### Azure OpenAI\n\n```yaml\nproviders:\n  - key: azure\n    type: azure\n    api_key: your-key\n    resource_name: your-resource\n    api_version: \"2023-05-15\"\n```\n\n### AWS Bedrock\n\n```yaml\nproviders:\n  - key: bedrock\n    type: bedrock\n    region: us-east-1\n    # Uses IAM roles or AWS credentials\n```\n\n### Google VertexAI\n\nSupports two authentication modes that route to different Google APIs:\n\n```yaml\n# Option 1: API Key (uses Gemini Developer API)\nproviders:\n  - key: vertexai\n    type: vertexai\n    api_key: your-gemini-api-key\n\n# Option 2: Service Account (uses Vertex AI)\nproviders:\n  - key: vertexai\n    type: vertexai\n    project_id: your-project\n    location: us-central1\n    credentials_path: /path/to/service-account.json\n```\n\n| Auth Method | API Endpoint | Use Case |\n|-------------|--------------|----------|\n| API Key | `generativelanguage.googleapis.com` | Simple setup, development |\n| Service Account | `{location}-aiplatform.googleapis.com` | Enterprise, GCP-integrated |\n\n## Environment Variables\n\n| Variable | Description | Default | Required |\n|----------|-------------|---------|----------|\n| `HUB_MODE` | Deployment mode: `yaml` or `database` | `yaml` | No |\n| `CONFIG_FILE_PATH` | Path to YAML config file | `config.yaml` | YAML mode |\n| `DATABASE_URL` | PostgreSQL connection string | - | Database mode |\n| `DB_POLL_INTERVAL_SECONDS` | Config polling interval | `30` | No |\n| `PORT` | Gateway server port | `3000` | No |\n| `MANAGEMENT_PORT` | Management API port | `8080` | Database mode |\n\n## Development\n\n### Prerequisites\n\n- Rust 1.88+\n- PostgreSQL 12+ (for database mode)\n- `sqlx-cli` (for migrations)\n\n### Commands\n\n```bash\n# Build\ncargo build\n\n# Test\ncargo test\n\n# Format\ncargo fmt\n\n# Lint\ncargo clippy\n\n# Run YAML mode\ncargo run\n\n# Run database mode\nHUB_MODE=database DATABASE_URL=postgresql://... cargo run\n```\n\n### Database Setup (for Database Mode)\n\n```bash\n# Install sqlx-cli\ncargo install sqlx-cli --no-default-features --features postgres\n\n# Run migrations\nsqlx migrate run\n```\n\n## Observability\n\n### OpenTelemetry Tracing\n\nConfigure OTLP endpoint for distributed tracing:\n\n```bash\nOTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317\n```\n\n### Prometheus Metrics\n\nAvailable at `/metrics`:\n\n- Request counts and latencies\n- Provider-specific metrics\n- Error rates\n- Active connections\n\n### OpenObserve Integration\n\nFor metrics monitoring, use OpenObserve:\n\n1. Deploy OpenObserve\n2. Configure Prometheus remote write to OpenObserve\n3. Query metrics in OpenObserve dashboard\n\n## Architecture Overview\n\n```\n┌─────────────────┐    ┌──────────────────┐    ┌─────────────────┐\n│   Client App    │───▶│     AiHub        │───▶│   LLM Provider  │\n└─────────────────┘    │                  │    │  (OpenAI, etc.) │\n                       │  ┌─────────────┐ │    └─────────────────┘\n                       │  │ Config Mode │ │\n                       │  │ YAML | DB   │ │    ┌─────────────────┐\n                       │  └─────────────┘ │───▶│   Observability │\n                       │                  │    │ (OTel, Metrics) │\n                       │  ┌─────────────┐ │    └─────────────────┘\n                       │  │ Management  │ │\n                       │  │ API (DB)    │ │\n                       │  └─────────────┘ │\n                       └──────────────────┘\n```\n\n## License\n\nLicensed under the MIT License. See [LICENSE](LICENSE) for details.\n\n## Contributing\n\nWe welcome contributions! Please see our Contributing Guide for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flongcipher%2Faihub","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flongcipher%2Faihub","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flongcipher%2Faihub/lists"}