Skip to content
Nikhil Kumar Reddy
← All work
retrieval2026

MedSignal API

Hybrid retrieval across live FDA data, PubMed and a local index — hardened against adversarial input.

<11ms
Input validationmeasured in repo
3.7–5.9s
End-to-end querymeasured in repo
14
Adversarial tests passedmeasured in repo
0.80–0.85
Typical confidence scoremeasured in repo
01

The problem

A manual pharmacovigilance workflow takes four to eight hours, and the evidence lives in three places with different shapes: live FDA adverse event statistics, recent PubMed papers, and a corpus of biomedical abstracts. Querying them in sequence is slow enough that nobody would use the API. Querying them in parallel means handling partial failure, because one of three sources will be down.

02

Architecture

Three retrievals fire simultaneously via asyncio.gather — openFDA for real-time adverse event statistics, PubMed for recent papers, and a FAISS index over roughly 1,500 pre-embedded biomedical abstracts using PubMedBERT embeddings. Results merge and deduplicate before synthesis. Validation runs first and hard: Pydantic v2 rejects malformed requests in under 11ms, before a single external call is made, so bad input costs nothing.

03

What broke

The scope limitation is severe and worth stating plainly: it supports two drugs, semaglutide and metformin, and rejects brand names entirely. That makes it a proof of concept, not a product. The grounding layer also forces evidence-based responses with explicit confidence scores in the 0.80–0.85 range, but those scores are the model's self-assessment rather than a calibrated measure — they indicate confidence, not correctness.

04

Results

Four to eight hours of manual work collapses into a single API call returning in under six seconds. Fourteen adversarial tests pass, including SQL injection and prompt injection attempts — the validation layer rejecting bad input in under 11ms means attacks never reach the expensive path.