Self-Hosted AI Backend

Open Keyboard LLM Gateway

A lightweight TypeScript gateway for privacy-first AI writing workflows and local model routing.

This project supports Open Keyboard, an AI writing workflow where the keyboard client can call a controlled backend instead of talking directly to a model provider.

The gateway authenticates client keys, rate-limits requests, exposes OpenAI-compatible chat completions, and routes requests to local Ollama models. It keeps model infrastructure under user control while preserving a simple client integration surface.

What this demonstrates: Practical backend architecture for self-hosted AI tools, including auth, model access control, admin operations, Docker deployment, and tests around critical API behavior.

API
OpenAI
Compatible
Chat completion surface
Auth
Keys
Client Access
Hot-reloaded API keys
Run
Docker
Deployment
Containerized gateway
Tests
Vitest
Coverage
API and middleware behavior

Technical Highlights

Auth

API Key Authentication

Validates bearer keys, supports key enablement and revocation, and restricts access before model requests reach the proxy layer.

Limits

Rate Limiting

Applies per-key request limits so keyboard clients and experiments can share the backend without uncontrolled traffic.

Models

Local Model Routing

Routes OpenAI-compatible chat requests to Ollama, enabling local model use without changing the client integration pattern.

Admin

Admin Operations

Includes an admin API and UI path for key management, model configuration, and operational control of client access.

Technology Stack

Gateway

TypeScript Hono Node.js CORS JSON logging

Runtime

Docker Ollama OpenAI-compatible API Vitest Admin API

Repository Entry Points

The project is structured around a small gateway core, middleware for request control, and deployment files for local hosting.

Review the gateway implementation, the client project it supports, and the self-hosted AI workflow behind the keyboard experience.