How wyeeeee/hajimi works
HAJIMI is a FastAPI proxy that accepts OpenAI-compatible chat and model requests, converts them for Gemini, and returns streamed or complete responses. A parallel Vertex AI mode provides model listing and chat completion. API keys, caching, limits, usage statistics, and configuration support the request lifecycle; web dashboards expose configuration, status, and logs, while the page UI also includes backend selection. Several dashboard and Vertex internals are unsampled, so uncertain UI/API wiring is marked unverified or omitted.
Main entry points: routes.py API routes · main.py FastAPI app · nonstream_handlers.py Completion handlers · chat_api.py Vertex chat
Components 30
Gemini proxy
- FastAPI app
app/main.py - API routes
app/api/routes.py - Request schemas
app/models/schemas.py - Stream handlers
app/api/stream_handlers.py - Completion handlers
app/api/nonstream_handlers.py - Gemini client
app/services/gemini.py - OpenAI conversion
app/services/OpenAI.py
Vertex mode
- Vertex auth
app/vertex/auth.py - Vertex chat
app/vertex/routes/chat_api.py - Vertex models API
app/vertex/routes/models_api.py - Message processing
app/vertex/message_processing.py - Model loader
app/vertex/model_loader.py - Vertex initialization
app/vertex/vertex_ai_init.py - Vertex configuration
app/vertex/config.py
Shared services
- Runtime settings
app/config/settings.py - Config persistence
app/config/persistence.py - API key management
app/utils/api_key.py - Response cache
app/utils/cache.py - Rate limits
app/utils/rate_limiting.py - Usage statistics
app/utils/stats.py - Error handling
app/utils/error_handling.py - Log management
app/utils/logging.py
Web interfaces
- Dashboard API
app/api/dashboard.py - Dashboard UI
hajimiUI/src/views/DashboardView.vue - Dashboard state
hajimiUI/src/stores/dashboard.js - Unified web UI
page/src/views/DashboardView.vue - Backend selection
page/src/stores/backend.js
Other components
- API client
- Google Gemini
- Vertex AI
Connections 31
- API client → FastAPI app: sends requests
README.md - FastAPI app → API routes: mounts routes
app/main.py - API routes → Stream handlers: dispatches streaming
app/api/routes.py - API routes → Completion handlers: dispatches completion
app/api/routes.py - API routes → Request schemas: validates with
app/api/routes.py - Stream handlers → Gemini client: calls
app/api/stream_handlers.py - Completion handlers → Gemini client: calls
app/api/nonstream_handlers.py - Gemini client → Google Gemini: requests models
- API routes → API key management: uses keys
- Completion handlers → Response cache: reads and writes
app/api/nonstream_handlers.py - Completion handlers → Usage statistics: updates usage
app/api/nonstream_handlers.py - Stream handlers → Usage statistics: updates usage
app/api/stream_handlers.py - Completion handlers → Error handling: handles failures
app/api/nonstream_handlers.py - API routes → Rate limits: applies limits
- FastAPI app → Config persistence: initializes settings
app/main.py - Config persistence → Runtime settings: loads and saves
app/config/persistence.py - FastAPI app → Vertex initialization: initializes Vertex
app/main.py - API routes → Vertex models API: delegates model listing
app/api/routes.py - API routes → Vertex chat: delegates chat
app/api/routes.py - Vertex chat → Vertex auth: checks credentials
app/vertex/routes/chat_api.py - Vertex models API → Vertex auth: checks credentials
app/vertex/routes/models_api.py - Vertex chat → Message processing: processes messages
app/vertex/routes/chat_api.py - Vertex models API → Model loader: loads model list
app/vertex/routes/models_api.py - Vertex initialization → Model loader: initializes models
app/vertex/vertex_ai_init.py - Vertex initialization → Vertex configuration: uses settings
app/vertex/vertex_ai_init.py - Vertex chat → Vertex AI: sends inference
- FastAPI app → Dashboard API: mounts dashboard
- Dashboard UI → Dashboard state: uses state
hajimiUI/src/views/DashboardView.vue - Dashboard state → Dashboard API: requests dashboard data
- Unified web UI → Backend selection: uses backend state
page/src/views/DashboardView.vue - Unified web UI → Dashboard state: uses dashboard state
page/src/views/DashboardView.vue