KeyCompute is a high-performance, scalable, and ready-to-use AI computing power service platform. KeyCompute 是新一代高性能,易拓展,开箱即用的 AI Token 算力租赁与聚合服务平台。
KeyCompute is a high-performance, extensible, and out-of-the-box AI token compute service platform, providing enterprise-grade capabilities including unified LLM access, smart routing, metering and billing, compute node leasing, multi-level distribution, and observability.
Pure Rust Full Stack: Backend (Axum) + Frontend (Dioxus WASM) + CLI client, sharing types and logic, ultimate performance and security.
Note: This project is for personal learning only. You must use it in compliance with OpenAI Terms of Use and applicable laws and regulations. Do not use it for illegal purposes. In accordance with the Interim Measures for the Administration of Generative Artificial Intelligence Services, do not provide any unregistered generative AI services to the public in China.
Compute nodes connect via pull-based polling without requiring a public IP. They run hosted models on local hardware and earn rewards based on contributions.
node: to explicitly route requests to the node poolSeamlessly switch between all major models with the standard OpenAI API — just one line of code:
| Provider | Model Families | Implementation |
|---|---|---|
| OpenAI | GPT-4o / GPT-4 / GPT-3.5 etc. | ✅ |
| Anthropic | Claude 3.5 Sonnet / Opus / Haiku etc. | ✅ |
| Gemini 1.5 / 2.0 Flash / Pro etc. | ✅ | |
| DeepSeek | DeepSeek-V3 / R1 / Chat etc. | ✅ |
| Ollama | Local models (Llama / Qwen / GLM / MiniMax etc.) | ✅ |
| vLLM | Self-hosted models | ✅ |
GLM (Zhipu) and MiniMax can be deployed locally via the Ollama adapter, not as standalone Provider implementations.
Two-layer routing architecture with multi-factor weighted scoring for optimal selection:
score = 0.30 × Cost Factor + 0.25 × Latency Factor + 0.25 × Success Rate + 0.20 × Health Statussk-..., API access)/health endpoint for one-click service status monitoring[Client: Web / Desktop / Mobile (Dioxus)]
↕ HTTP/SSE
[API Layer: keycompute-server (Axum)]
├── Authentication (JWT + API Key)
├── Rate Limiting (In-memory/Redis)
├── Routing (Two-layer engine)
└── Gateway (Single upstream execution layer)
↕
[Provider Adapter Layer]
├── OpenAI / Anthropic / Google
├── DeepSeek
├── Ollama (Local models)
└── vLLM (Self-hosted)
[Compute Node Network]
node-token (CLI) ↔ node-gateway ↔ Redis task queue ↔ Local inference| Component | Version Requirement |
|---|---|
| Rust | ≥ 1.92 |
| Axum | ≥ 0.8.0 |
| Dioxus | ≥ 0.7.1 (frontend development) |
| PostgreSQL | ≥ 16 |
| Redis | ≥ 7 (optional, for distributed rate limiting/node queue) |
| Docker | Latest (container deployment) |
…After deployment, visit http://localhost to get started (or use the port set by WEB_PORT).
Unless overridden, the bootstrap administrator email is [email protected].
Its password is the value you set in KC__DEFAULT_ADMIN_PASSWORD; production
never accepts change-me-admin-password for a fresh database. After the first
system administrator has been created, remove this one-time password from the
environment; later restarts do not require it.
⚠️ Security Warning: The default values shown below (
change-me-*) are for demonstration only. Never use these in production! Generate strong random passwords using:openssl rand -base64 32An ordinary
cargo runbuilds the debug executable, so the startup method itself selects development mode. It reads onlyconfig.toml, may use public local credentials, and may listen on0.0.0.0..env.example,KC__*, andAPP_BASE_URLcannot override that file. Never reuse it in production.
# Create the cargo-run configuration
cp config.example.toml config.toml
# Start PostgreSQL and Redis with host-local ports matching config.toml
docker compose --env-file .env.example -f docker-compose.yml -f docker-compose.dev.yml up -d postgres redis
# Install dioxus-cli
curl -sSL http://dioxus.dev/install.sh | sh
# Start the backend
cargo run -p keycompute-server
# Start the frontend development server (in another terminal)
dx serve --package web --platform web --hot-reload true --addr 0.0.0.0cargo run -p keycompute-server --release and the Docker image select
production mode. The release executable reads environment variables and ignores
config.toml; no configuration parameter or environment variable can change
the runtime mode.
…This table applies to release/Docker production startup. A debug cargo run
uses config.toml instead.
| Variable | Description | Required |
|---|---|---|
KC__DATABASE__URL |
PostgreSQL connection string | ✅ |
KC__AUTH__JWT_SECRET |
Production: non-default/non-blank JWT signing secret, at least 32 bytes | ✅ |
KC__CRYPTO__SECRET_KEY |
Production: Base64 encoding of exactly 32 bytes; cannot be changed after Provider API keys are written | ✅ |
KC__NODE_GATEWAY__REGISTRATION_TOKEN_SECRET |
Production with Redis: non-default HMAC signing secret of at least 16 bytes; issues one-time node registration tokens | Conditional |
KC__REDIS__URL |
Redis connection string (optional; without it: rate limiter falls back to in-memory, cache no-ops, node gateway unavailable) | ⚪ |
KC__EMAIL__SMTP_HOST |
SMTP host (optional) | ⚪ |
KC__EMAIL__SMTP_PORT |
SMTP port (optional) | ⚪ |
KC__EMAIL__SMTP_USERNAME |
SMTP username (optional) | ⚪ |
KC__EMAIL__SMTP_PASSWORD |
SMTP password (optional) | ⚪ |
KC__EMAIL__FROM_ADDRESS |
Sender email address (optional) | ⚪ |
KC__EMAIL__FROM_NAME |
Sender display name (optional) | ⚪ |
KC__EMAIL__REQUIREMENT_RECIPIENT |
Requirement collection recipient email (optional; required to receive homepage submissions) | ⚪ |
APP_BASE_URL |
Current deployment's public frontend URL; required when SMTP is enabled and before enabling public invite links | Conditional |
KC__DEFAULT_ADMIN_EMAIL |
Default administrator email (optional) | ⚪ |
KC__DEFAULT_ADMIN_PASSWORD |
One-time bootstrap password: required only when production creates the first system administrator; non-default/non-blank and at least 12 characters |
Conditional |
# Chat Completions (streaming + non-streaming)
curl http://localhost:3000/v1/chat/completions \
-H "Authorization: Bearer sk-xxx" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-chat",
"messages": [{"role": "user", "content": "Hello!"}],
"stream": true
}'
# List available models (defaults to the openai ingress protocol)
# Pass ?protocol=anthropic to list anthropic-protocol models instead
curl http://localhost:3000/v1/models \
-H "Authorization: Bearer sk-xxx"The Responses API is available through POST /v1/responses and a WebSocket
upgrade on GET /v1/responses. KeyCompute's WebSocket mode currently accepts
response.create events only; connection-control events such as
response.steer and response.inject are not supported.
| Category | Endpoint | Description |
|---|---|---|
| Auth | POST /api/v1/auth/register |
User registration |
POST /api/v1/auth/login |
User login | |
POST /api/v1/auth/forgot-password |
Forgot password | |
| User | GET /api/v1/me |
Current user info |
GET/POST /api/v1/keys |
API Key management | |
| Billing | GET /api/v1/usage |
Usage statistics |
GET /api/v1/billing/records |
Billing records | |
| Payment | POST /api/v1/payments/orders |
Create payment order |
GET /api/v1/payments/balance |
Balance inquiry | |
| Distribution | GET /api/v1/me/distribution/earnings |
Distribution earnings |
| Node | GET /api/v1/me/node-gateway/token |
Node token |
GET /api/v1/me/tips |
Tip summary | |
| Admin | GET/POST /api/v1/accounts |
Upstream account management |
GET/POST /api/v1/settings |
System settings | |
GET/POST /api/v1/pricing |
Pricing management | |
GET /api/v1/admin/monitoring/overview |
Monitoring overview |
For complete API documentation, refer to the route definitions in the project source code.
…We welcome contributions of all kinds. Please read CONTRIBUTING.md to learn how to get involved.
No open issues yet, or sync has not completed.