{"slug": "building-a-medical-investigation-ai-on-an-openai-compatible-api", "title": "Building a Medical Investigation AI on an OpenAI-Compatible API", "summary": "Premedice, a medical investigation AI, has been built on an OpenAI-compatible API endpoint that lets developers swap in its base URL, API key, and Premed-4 model without changing existing client code. The system runs a 128K-token context window with eight always-on medical tools — including PubMed, OpenFDA, RxNorm, DailyMed, ClinicalTrials.gov, Semantic Scholar, and Europe PMC — and returns structured briefs covering signals, evidence, correlations, gaps, and a decision-support boundary rather than single-prompt answers.", "body_md": "November 6, 2026 | 8 min read\n\nMost medical AI demos are a chat box with a medical prompt.\n\nYou send a symptom. You get a paragraph. It can look impressive in a screenshot. Then you try to use it on a real case and discover the hard parts: the record is fragmented, the values have dates, the medications interact, the evidence needs a source, and the model has no idea what it does not know.\n\nPremedice is a medical investigation AI. The product is built around a different unit of work: the whole case, not the single question.\n\nThis post is a technical look at how that works, and how to call the API from your own stack.\n\nTHE PROBLEM WITH A SINGLE PROMPT\n\nA standard medical RAG pipeline retrieves a few passages and asks a model to answer. That is useful for general questions. It is not enough for an investigation.\n\nAn investigation needs four things a single retrieval call usually lacks.\n\nTemporal context. A potassium of 5.3 means something different if it was 4.1 last month. A medication started nine days ago matters. A lab trend matters. A snapshot does not.\n\nTool access. The answer may depend on a drug label, an interaction database, a clinical trial, or a guideline. Retrieval alone does not check those sources.\n\nA citation trail. A high-stakes claim without a source is a hypothesis. The user needs to inspect the basis, not just read the conclusion.\n\nExplicit uncertainty. A good investigation names the gaps. What is missing? Which value conflicts? Which symptom has no explanation yet?\n\nThat is the design brief for a medical investigation AI.\n\nWHAT \"MEDICAL INVESTIGATION AI\" MEANS\n\nMedical investigation AI is software that takes a health question and investigates it across the full available record, rather than generating an answer from a single prompt.\n\nIt collects the history, labs, medications, documents, and symptoms. It correlates changes over time. It verifies claims against literature and drug sources. It states what is missing. Then it returns a structured brief for a human to review.\n\nPremedice is built for that job. It is not a diagnosis engine. It is an investigation layer that sits between the record and the clinician.\n\nTHE ARCHITECTURE, IN PRACTICAL TERMS\n\nPremedice exposes an OpenAI-compatible endpoint. If you already use the OpenAI SDK, you change the base URL, the API key, and the model name. The rest of your client code stays the same.\n\nBase URL: [https://api.premedice.com/v1](https://api.premedice.com/v1)\n\nModel: Premedice/Premed-4\n\nContext window: 128K tokens\n\nMax output: 16K tokens\n\nStreaming: OpenAI SSE\n\nTools: eight medical tools are preloaded on every request. PubMed, OpenFDA, RxNorm, DailyMed, ClinicalTrials.gov, Semantic Scholar, Europe PMC, and create_file.\n\nThe tools are always on. That is a deliberate product decision. A medical investigation should not require the caller to remember which database to attach. The model should be able to check the label, the interaction, the trial, and the literature as part of the investigation.\n\nThe response includes the answer and its sources. The exact shape is the normal chat completion shape, so existing streaming, retries, and logging code should carry over.\n\nWHAT A GOOD RESPONSE SHOULD CONTAIN\n\nA medical investigation AI should return more than a paragraph. A useful brief has five parts.\n\nThe signals. The values or findings that changed and deserve attention.\n\nThe evidence. The source value, trend, guideline, label, or paper behind each signal. The reader should be able to check it.\n\nThe correlations. The medication, condition, or history that may explain the signal. Correlation is not causation, and the brief should say so.\n\nThe gaps. The missing history, the conflicting value, the symptom that has no explanation yet.\n\nThe boundary. A clear statement that the output is decision support, not a diagnosis, and that urgent symptoms need urgent care.\n\nIf your medical AI output does not have those five parts, it is probably a chat response, not an investigation.\n\nDESIGN LESSONS\n\nThree lessons shaped the product.\n\nPreload the tools. A medical investigation should not fail because the caller did not attach the right database. The tools are part of the investigation environment, not an optional plugin.\n\nMake citations first-class. A citation is not a footnote added after the fact. It is part of the answer. If a high-stakes claim cannot be tied to a source, the claim should be marked as uncertain.\n\nKeep the uncertainty visible. Models are good at sounding complete. A medical investigation AI has to be good at sounding incomplete when the evidence is incomplete. That is a product behavior, not just a prompt.\n\nThe model matters too, but it is not the whole product. Premedice 4 scored 84.6 percent on an internal MedQA replication. That is an exam-style benchmark, not a clinical validation or an outcome study. It has not been peer-reviewed. It is a signal about reasoning, not proof of accuracy in a real patient.\n\nBenchmarks are a floor, not a finish line.\n\nWHAT TO BUILD WITH IT\n\nThe API is useful anywhere a developer needs a cited medical investigation rather than a generic answer.\n\nPatient education tools that explain labs in plain language and show the source.\n\nClinical preparation tools that assemble a pre-visit brief from a record.\n\nResearch prototypes that need to correlate labs, medications, and literature.\n\nCaregiver tools that help someone organize a family member's records and questions.\n\nSecond-opinion workflows that review the whole case against the evidence.\n\nThe API is not a diagnosis engine. It is not a telehealth service. It is not an emergency service. It is a reasoning and evidence layer that a human should review.\n\nSAFETY AND PRIVACY FOR DEVELOPERS\n\nIf you are building in health, the non-negotiables are not optional.\n\nUse a lawful basis for processing. Do not send identifiable data without consent or another valid legal basis.\n\nKeep API keys server-side. A pm_live key is a secret. Do not ship it in a client bundle.\n\nLog carefully. Do not store full patient records in application logs or error trackers.\n\nRespect the boundary. Do not present the output as a diagnosis. Do not use it for emergency triage.\n\nCheck the data flow. Premedice is designed around GDPR-native, EU-resident data handling, with AES-256 at rest and TLS 1.3 in transit. User data is not used for model training. The API is a developer surface, but your application still needs its own privacy review.\n\nFor a clinical deployment, a clinic still needs a data protection impact assessment, a retention policy, a clinical safety review, and a clear escalation path.\n\nPRICING AND ACCESS\n\nAPI keys are generated in the Premedice dashboard. Billing uses the same per-token rates as the in-app chat and is debited from the account's token balance.\n\nThe app itself has a free tier. Pro is 5.99 EUR per month, and Advanced is 20 EUR per month. The API is the developer path for teams that want to integrate the investigation into their own product.\n\nGETTING STARTED\n\nRead the API docs at api.premedice.com/docs.\n\nCreate a key in the Premedice dashboard.\n\nPoint your OpenAI SDK at [https://api.premedice.com/v1](https://api.premedice.com/v1).\n\nUse the model name Premedice/Premed-4.\n\nSend a synthetic case first. Check the citations. Check the uncertainty. Then decide whether the output is good enough for your workflow.\n\nKEY TAKEAWAYS\n\nIs the API OpenAI-compatible?\n\nYes. Use the base URL [https://api.premedice.com/v1](https://api.premedice.com/v1), your Premedice key, and the model Premedice/Premed-4.\n\nWhich tools are preloaded?\n\nPubMed, OpenFDA, RxNorm, DailyMed, ClinicalTrials.gov, Semantic Scholar, Europe PMC, and create_file. They are on by default.\n\nDoes the API diagnose patients?\n\nNo. It is decision support. It does not diagnose, prescribe, or replace a clinician.\n\nIs patient data used for training?\n\nNo. Premedice states that user data is not used for model training.\n\nWhere are the docs?\n\n[https://api.premedice.com/docs](https://api.premedice.com/docs)\n\nSOURCES\n\nPremedice 4 model page.\n\n[https://premedice.com/models/premedice-4/](https://premedice.com/models/premedice-4/)\n\nPremedice API documentation.\n\n[https://api.premedice.com/docs](https://api.premedice.com/docs)\n\nJin D, et al. What Disease Does This Patient Have? A Large-Scale Open Domain Question Answering Dataset from Medical Exams. arXiv:2009.13081.\n\n[https://arxiv.org/abs/2009.13081](https://arxiv.org/abs/2009.13081)\n\nWorld Health Organization. Patient safety.\n\n[https://www.who.int/news-room/fact-sheets/detail/patient-safety](https://www.who.int/news-room/fact-sheets/detail/patient-safety)\n\nCOVER IMAGE\n\nReady to use: [https://premedice.com/og-home.jpg](https://premedice.com/og-home.jpg) (1200 x 630)\n\nAlt text: Premedice medical investigation AI product preview with a cited answer interface.\n\nCustom cover direction: a terminal window beside a lab report, with three values highlighted and a source list on the right. No stock photos, no robot hands, no blue-purple gradient.", "url": "https://wpnews.pro/news/building-a-medical-investigation-ai-on-an-openai-compatible-api", "canonical_source": "https://dev.to/ridwan_zunaid_40c272be561/building-a-medical-investigation-ai-on-an-openai-compatible-api-1cfe", "published_at": "2026-11-06 07:12:00+00:00", "updated_at": "2026-11-06 07:23:03.588037+00:00", "lang": "en", "topics": ["artificial-intelligence", "ai-products", "ai-tools", "ai-agents", "large-language-models"], "entities": ["Premedice", "Premed-4", "OpenAI", "PubMed", "OpenFDA", "RxNorm", "ClinicalTrials.gov", "Semantic Scholar"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/building-a-medical-investigation-ai-on-an-openai-compatible-api", "markdown": "https://wpnews.pro/news/building-a-medical-investigation-ai-on-an-openai-compatible-api.md", "text": "https://wpnews.pro/news/building-a-medical-investigation-ai-on-an-openai-compatible-api.txt", "jsonld": "https://wpnews.pro/news/building-a-medical-investigation-ai-on-an-openai-compatible-api.jsonld"}}