Skip to content

paulsojan/context-gate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ContextGate

ContextGate is a prompt compression API that automatically compresses and normalizes prompts before they hit your LLM — lowering costs, latency, and context bloat.

It removes redundancy, filters noise, and semantically deduplicates content through a multi-stage pipeline, returning a cleaner, more efficient prompt.

Architecture

Architecture

API Overview

All endpoints are under /api/v1/.

Method Endpoint Auth Description
POST /signup Register a new account
POST /login
POST /refresh Exchange refresh token for new access token
POST /logout Bearer
GET /me Bearer Current user
POST /compress/text X-API-Key Compress plain text
POST /compress/pdf X-API-Key Upload PDF, compress extracted text
GET /api_keys Bearer List your API keys
POST /api_keys Bearer Create an API key
DELETE /api_keys/{id} Bearer Revoke an API key
GET /admin/customers Admin List all customers and their keys
DELETE /admin/customers/{uid}/api_keys/{kid} Admin Revoke a customer's key

Local Setup

Prerequisites

  • Python 3.12+
  • Node.js 22+ and Yarn
  • PostgreSQL

Backend

1. Install dependencies

The backend uses uv as its package manager.

cd backend
uv sync

2. Activate env

source .venv/bin/activate

3. Configure environment

Copy the example file and fill in your values:

cp .env.example .env

4. Download ML models

The semantic deduplication stage requires a local copy of all-MiniLM-L6-v2. Download it once:

uv run python scripts/download_models.py

5. Run database migrations

uv run alembic upgrade head

6. Create an admin user

uv run python scripts/create_admin.py \
  --email admin@example.com \
  --password secret \
  --first-name Admin \
  --last-name User

7. Start the server

fastapi dev

The API will be available at http://localhost:8000. Interactive docs at http://localhost:8000/docs.

Frontend

1. Install dependencies

cd frontend
yarn install

2. Configure environment

cp .env.local.example .env.local

3. Start the dev server

yarn dev

Open http://localhost:3000. Log in with the admin account created above, or sign up as a new customer.

About

ContextGate compresses and normalizes prompts before they reach your LLM—reducing cost, latency, and context bloat.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors