BYOK AI Platform with 14 OptiLLM Techniques
1
stars
62
commits
Python
primary language
Jan 17, 2026
updated
A 2-pillar BYOK (Bring-Your-Own-Key) AI platform that supercharges LLMs with advanced inference techniques and agentic workflows.
Merlin is a production-ready AI workbench with:
Key Differentiator: Not another ChatGPT clone. Merlin demonstrates advanced AI engineering with workflow orchestration, external API integration, and inference optimization directly integrated into the backend.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ MERLIN AI WORKBENCH โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ Pillar 1: Performance Hub โ
โ โโ Next.js 15 Frontend (SSE streaming, session management) โ
โ โโ FastAPI Backend (encrypted keys, chat API, rate limiting) โ
โ โโ Integrated OptiLLM (inference optimization, direct calls) โ
โ โ
โ Pillar 2: Agentic Workflow Engine โ
โ โโ Workflow Orchestrator (6 step types, approval gates) โ
โ โโ External APIs (GPTZero, Undetectable AI) โ
โ โโ Essay Writer Template (plan โ draft โ humanize โ detect) โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
git clone <repository-url>
cd merlin
# Copy the example environment file
cp .env.example .env
# Generate a Fernet key for encryption
python -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())"
# Edit .env and add your generated FERNET_KEY
docker-compose up --build
The application will be available at:
Backend (with integrated OptiLLM):
cd backend
pip install -e .
fastapi dev src/merlin/main.py --port 8001
Frontend:
cd frontend
npm install
npm run dev
Note: OptiLLM is now directly integrated into the FastAPI backend - no separate proxy server needed!
merlin/
โโโ frontend/ # Next.js 15 application
โ โโโ src/
โ โ โโโ app/ # App Router pages
โ โ โ โโโ (chat)/ # Chat interface
โ โ โ โโโ (settings)/ # Settings pages
โ โ โ โโโ page.tsx # Landing page
โ โ โโโ components/ # React components
โ โ โโโ lib/ # Utilities and state
โ โโโ package.json
โโโ backend/ # FastAPI application
โ โโโ src/merlin/
โ โ โโโ api/ # API routes
โ โ โโโ core/ # Config and security
โ โ โโโ db/ # Database models
โ โ โโโ optillm/ # Integrated OptiLLM techniques
โ โ โโโ repositories/ # Data access layer
โ โ โโโ services/ # Business logic (including OptiLLMService)
โ โ โโโ main.py # FastAPI app entry
โ โ โโโ schemas/ # Pydantic models
โ โโโ pyproject.toml
โโโ docker-compose.yml # Orchestration
โโโ README.md
FERNET_KEY) must be securely generated and stored.env files or expose the FERNET_KEYmerlin.db) contains encrypted keys - protect it accordinglycd frontend && npm run dev (hot reload on http://localhost:3000)cd backend && fastapi dev src/merlin/main.py (hot reload on http://localhost:8001)npm run type-check (frontend), mypy src (backend)npm run lint (frontend), ruff check src (backend)npm test (frontend), pytest (backend)Merlin supports 9 optimization techniques via OptiLLM, integrated directly into the backend. Techniques are applied sequentially in the order specified and can dramatically improve response quality.
plansearch + cot_reflection (10 calls)moa + bon (12 calls)mcts alone (15 calls)plansearch + cot_reflection + moa + bon + self_consistency + mcts (40+ calls)mcts + rstar (25+ calls)Error: "Value is not a struct" or Provider Validation Errors
moa.py - Sanitizes queries for critique and final synthesis promptsplansearch.py - Strips code blocks from all problem statements; normalizes implementation responsesmcts.py - Cleans initial queries and synthesized follow-up promptsrstar.py - Returns natural-language answers with expanded numeric pattern matchingError: "Rate limit exceeded"
Error: "Could not generate any completions"
Techniques taking too long
To ensure compatibility with all providers (especially Google Gemini), we've implemented automatic code block sanitization across all OptiLLM techniques:
# 1. Create workflow from template
POST /api/v1/workflows/templates/essay-writer
{
"goal": "Write a 1000-word essay on the American Revolution",
"word_count": 1000,
"style": "academic"
}
# 2. Execute workflow (6 steps with approval gates)
POST /api/v1/workflows/{workflow_id}/execute
# Steps execute sequentially:
# โ PLAN: Create outline (plansearch technique)
# โ DRAFT: Write full essay (Claude, cot_reflection)
# โ VERIFY: Check requirements (GPT-4o)
# โ HUMANIZE: Undetectable AI humanization
# โ INTEGRITY_CHECK: Verify content preservation
# โ AI_DETECTION: GPTZero detection score
# 3. Approve each step
POST /api/v1/workflows/{workflow_id}/steps/{step_index}/approve
{"approved": true, "feedback": "Looks great!"}
Merlin integrates with:
See EXTERNAL_APIS.md for setup instructions and API details.
MIT
Contributions are welcome! Please:
Built to showcase AI Engineering depth beyond simple ChatGPT clones.
61 commits
1 commits
Python
81.6%
TypeScript
17.6%
BYOK AI Platform with 14 OptiLLM Techniques
1
stars
62
commits
Python
primary language
Jan 17, 2026
updated
A 2-pillar BYOK (Bring-Your-Own-Key) AI platform that supercharges LLMs with advanced inference techniques and agentic workflows.
Merlin is a production-ready AI workbench with:
Key Differentiator: Not another ChatGPT clone. Merlin demonstrates advanced AI engineering with workflow orchestration, external API integration, and inference optimization directly integrated into the backend.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ MERLIN AI WORKBENCH โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ Pillar 1: Performance Hub โ
โ โโ Next.js 15 Frontend (SSE streaming, session management) โ
โ โโ FastAPI Backend (encrypted keys, chat API, rate limiting) โ
โ โโ Integrated OptiLLM (inference optimization, direct calls) โ
โ โ
โ Pillar 2: Agentic Workflow Engine โ
โ โโ Workflow Orchestrator (6 step types, approval gates) โ
โ โโ External APIs (GPTZero, Undetectable AI) โ
โ โโ Essay Writer Template (plan โ draft โ humanize โ detect) โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
git clone <repository-url>
cd merlin
# Copy the example environment file
cp .env.example .env
# Generate a Fernet key for encryption
python -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())"
# Edit .env and add your generated FERNET_KEY
docker-compose up --build
The application will be available at:
Backend (with integrated OptiLLM):
cd backend
pip install -e .
fastapi dev src/merlin/main.py --port 8001
Frontend:
cd frontend
npm install
npm run dev
Note: OptiLLM is now directly integrated into the FastAPI backend - no separate proxy server needed!
merlin/
โโโ frontend/ # Next.js 15 application
โ โโโ src/
โ โ โโโ app/ # App Router pages
โ โ โ โโโ (chat)/ # Chat interface
โ โ โ โโโ (settings)/ # Settings pages
โ โ โ โโโ page.tsx # Landing page
โ โ โโโ components/ # React components
โ โ โโโ lib/ # Utilities and state
โ โโโ package.json
โโโ backend/ # FastAPI application
โ โโโ src/merlin/
โ โ โโโ api/ # API routes
โ โ โโโ core/ # Config and security
โ โ โโโ db/ # Database models
โ โ โโโ optillm/ # Integrated OptiLLM techniques
โ โ โโโ repositories/ # Data access layer
โ โ โโโ services/ # Business logic (including OptiLLMService)
โ โ โโโ main.py # FastAPI app entry
โ โ โโโ schemas/ # Pydantic models
โ โโโ pyproject.toml
โโโ docker-compose.yml # Orchestration
โโโ README.md
FERNET_KEY) must be securely generated and stored.env files or expose the FERNET_KEYmerlin.db) contains encrypted keys - protect it accordinglycd frontend && npm run dev (hot reload on http://localhost:3000)cd backend && fastapi dev src/merlin/main.py (hot reload on http://localhost:8001)npm run type-check (frontend), mypy src (backend)npm run lint (frontend), ruff check src (backend)npm test (frontend), pytest (backend)Merlin supports 9 optimization techniques via OptiLLM, integrated directly into the backend. Techniques are applied sequentially in the order specified and can dramatically improve response quality.
plansearch + cot_reflection (10 calls)moa + bon (12 calls)mcts alone (15 calls)plansearch + cot_reflection + moa + bon + self_consistency + mcts (40+ calls)mcts + rstar (25+ calls)Error: "Value is not a struct" or Provider Validation Errors
moa.py - Sanitizes queries for critique and final synthesis promptsplansearch.py - Strips code blocks from all problem statements; normalizes implementation responsesmcts.py - Cleans initial queries and synthesized follow-up promptsrstar.py - Returns natural-language answers with expanded numeric pattern matchingError: "Rate limit exceeded"
Error: "Could not generate any completions"
Techniques taking too long
To ensure compatibility with all providers (especially Google Gemini), we've implemented automatic code block sanitization across all OptiLLM techniques:
# 1. Create workflow from template
POST /api/v1/workflows/templates/essay-writer
{
"goal": "Write a 1000-word essay on the American Revolution",
"word_count": 1000,
"style": "academic"
}
# 2. Execute workflow (6 steps with approval gates)
POST /api/v1/workflows/{workflow_id}/execute
# Steps execute sequentially:
# โ PLAN: Create outline (plansearch technique)
# โ DRAFT: Write full essay (Claude, cot_reflection)
# โ VERIFY: Check requirements (GPT-4o)
# โ HUMANIZE: Undetectable AI humanization
# โ INTEGRITY_CHECK: Verify content preservation
# โ AI_DETECTION: GPTZero detection score
# 3. Approve each step
POST /api/v1/workflows/{workflow_id}/steps/{step_index}/approve
{"approved": true, "feedback": "Looks great!"}
Merlin integrates with:
See EXTERNAL_APIS.md for setup instructions and API details.
MIT
Contributions are welcome! Please:
Built to showcase AI Engineering depth beyond simple ChatGPT clones.
61 commits
1 commits
Python
81.6%
TypeScript
17.6%