PromptForge is an agentic prompt refinement platform with a Next.js frontend and a FastAPI + LangGraph backend. It runs a creator/critic loop against OpenRouter models, stores runs in Postgres, and presents a modern studio UI for refining prompts.
- Frontend: Next.js app (Tailwind + Base UI)
- Backend: FastAPI + LangGraph + SQLAlchemy (async)
- LLM: OpenRouter via
langchain-openai - DB: PostgreSQL (asyncpg)
PromptForge/
├── frontend/
└── backend/
Prereqs: Python 3.13+, Postgres, OpenRouter API key
cd backend
uv syncCreate .env in backend/:
DATABASE_URL=postgresql+asyncpg://user:pass@host:5432/dbname
OPENROUTER_API_KEY=your_openrouter_key
ENV=development
DEBUG=TrueRun the API:
uv run uvicorn app.main:app --reload --port 8000Notes:
- On startup (in development), the backend will auto-create tables.
- If you run the backend from the repo root, it still finds
backend/.env.
Prereqs: Node 18+ (or Bun/PNPM)
cd frontend
npm installCreate frontend/.env.local:
NEXT_PUBLIC_API_BASE=http://localhost:8000Run the UI:
npm run devOpen: http://localhost:3000
| Variable | Required | Description |
|---|---|---|
DATABASE_URL |
Yes | Postgres async URL (postgresql+asyncpg://...) |
OPENROUTER_API_KEY |
Yes | OpenRouter API key |
ENV |
No | development or production |
DEBUG |
No | True/False |
| Variable | Required | Description |
|---|---|---|
NEXT_PUBLIC_API_BASE |
Yes | Backend URL (e.g., http://localhost:8000) |
The frontend sends creator_model and critic_model directly to the backend. The backend forwards them to OpenRouter without validation.
If a model ID isn’t supported by OpenRouter, the request will fail. Consider adding a backend /models endpoint or a validation list if you want guardrails.
- DB errors: confirm
DATABASE_URLuses thepostgresql+asyncpg://scheme. - CORS: backend allows all origins in development by default.
- Model errors: ensure the model name exists on OpenRouter.
If you want a single-command dev runner (frontend + backend), I can add one.