--- title: EHRAgent emoji: "🏥" colorFrom: blue colorTo: green sdk: docker app_port: 7860 pinned: false short_description: SQL-grounded question answering over MIMIC-III/IV and eICU --- # EHRAgent — backend FastAPI backend for the [EHRAgent](https://github.com/suyccc/EHRAgent) chat UI. Loads three EHRSQL benchmark databases (MIMIC-III, MIMIC-IV, eICU) and answers natural-language questions by running an LLM tool-calling loop with two read-only SQL tools (`get_schema`, `execute_sql`). ## Strict BYOK This Space **never reads** an OpenAI key from its environment. Every `/api/ask` request must include an `X-OpenAI-Api-Key` header with the caller's own key. Keys are not logged, persisted, or shared across requests. ## Endpoints - `GET /api/health` - `GET /api/config` → `{model, databases: [{id, label, ready}], byok_required: true}` - `POST /api/ask` → body `{question, db, question_id?}`. **Required header:** `X-OpenAI-Api-Key: sk-…`. ## Frontend The chat UI is a static Next.js export hosted separately (e.g. on GitHub Pages). It points at this Space via `NEXT_PUBLIC_BACKEND_URL` at build time. See the project repo for the source.