Premedice API
OpenAI-compatible medical AI endpoint with built-in clinical tools. Drop-in for any OpenAI SDK, Cursor, Continue.dev, or opencode.
Base URL:https://api.premedice.com/v1
How do I authenticate with the Premedice API?
All requests require a Premedice API key via Bearer token. Generate one from your dashboard.
Generate an API key from your Premedice dashboard. Keys start with pm_live_.
Header
Authorization: Bearer pm_live_abc123...
Rate Limits
| Limit | Value | Notes |
|---|---|---|
| Requests | 20 per 60 seconds | Per API key, for chat, labs, evidence, and MCP tools/call. Handshakes and listings do not count. |
| Daily token cap | None enforced | Credits are the gate. |
These are configured limits, not measured throughput. No latency, error-rate, uptime, or SLA figure is published.
How do I connect to the Premedice API?
Get started in under 2 minutes. Pick your tool.
opencode
Connect from the opencode CLI in two steps:
/connect
Select OpenAI compatible from the provider list, then enter:
Base URL: https://api.premedice.com/v1
API Key: pm_live_your_key_here
Model: Premedice/Premed-4
Create or edit opencode.json in your project root:
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"custom": {
"npm": "@ai-sdk/openai-compatible",
"name": "Medical AI",
"options": {
"baseURL": "https://api.premedice.com/v1",
"apiKey": "pm_live_your_key_here"
},
"models": {
"Premedice/Premed-4": {
"name": "Premedice 4",
"limit": {
"context": 128000,
"output": 4096
}
}
}
}
}
}
Cursor
Add Premedice as a custom model in Cursor:
1. Open Settings → Models
2. Under "OpenAI API Key", click the gear icon and add:
OpenAI API Key: pm_live_your_key_here
Override Base URL: https://api.premedice.com/v1
3. Select Premedice/Premed-4 from the model dropdown
Continue.dev
Add to your ~/.continue/config.yaml:
models:
- title: Premedice Medical
provider: openai
model: Premedice/Premed-4
apiBase: https://api.premedice.com/v1
apiKey: pm_live_your_key_here
VS Code (GitHub Copilot Chat)
Use with Continue.dev extension or any OpenAI-compatible extension:
{
"openai.apiKey": "pm_live_your_key_here",
"openai.baseUrl": "https://api.premedice.com/v1",
"openai.model": "Premedice/Premed-4"
}
Any OpenAI SDK (Python / Node.js)
import openai
client = openai.OpenAI(
api_key="pm_live_your_key_here",
base_url="https://api.premedice.com/v1"
)
response = client.chat.completions.create(
model="Premedice/Premed-4",
messages=[{"role": "user", "content": "What is the mechanism of action of metformin?"}]
)
print(response.choices[0].message.content)
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "pm_live_your_key_here",
baseURL: "https://api.premedice.com/v1",
});
const response = await client.chat.completions.create({
model: "Premedice/Premed-4",
messages: [{ role: "user", content: "What is the mechanism of action of metformin?" }],
});
console.log(response.choices[0].message.content);
How do I create a medical AI chat completion?
The /v1/chat/completions endpoint is identical to OpenAI's API. Send messages, receive medical AI responses.
/openapi.json.Request Body
| Field | Type | Required | Description |
|---|---|---|---|
model | string | No | Premedice/Premed-4 (default; auto-routes by plan). low, mid, or high force a tier the plan allows. |
messages | array | Yes | Array of message objects with role and content |
stream | boolean | No | Enable SSE streaming (default: true) |
temperature | number | No | Sampling temperature 0–2 (default: 0.3) |
max_tokens | integer | No | Max output tokens (default: 4096) |
top_p | number | No | Nucleus sampling parameter |
stop | string|array | No | Stop sequences |
user | string | No | Unique user identifier for abuse tracking |
Messages Format
{
"messages": [
{ "role": "system", "content": "You are a helpful assistant." },
{ "role": "user", "content": "What are the first-line treatments for hypertension?" }
]
}
Examples
curl https://api.premedice.com/v1/chat/completions \
-H "Authorization: Bearer pm_live_abc123..." \
-H "Content-Type: application/json" \
-d '{
"model": "Premedice/Premed-4",
"messages": [
{"role": "user", "content": "What is the CHA2DS2-VASc score for a patient with AF, age 72, hypertension, and diabetes?"}
]
}'
import requests
response = requests.post(
"https://api.premedice.com/v1/chat/completions",
headers={
"Authorization": "Bearer pm_live_abc123...",
"Content-Type": "application/json",
},
json={
"model": "Premedice/Premed-4",
"messages": [
{"role": "user", "content": "What is the CHA2DS2-VASc score for a patient with AF, age 72, hypertension, and diabetes?"}
],
},
)
print(response.json()["choices"][0]["message"]["content"])
const res = await fetch("https://api.premedice.com/v1/chat/completions", {
method: "POST",
headers: {
"Authorization": "Bearer pm_live_abc123...",
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "Premedice/Premed-4",
messages: [
{ role: "user", content: "What is the CHA2DS2-VASc score for a patient with AF, age 72, hypertension, and diabetes?" }
],
}),
});
const data = await res.json();
console.log(data.choices[0].message.content);
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "pm_live_abc123...",
baseURL: "https://api.premedice.com/v1",
});
const completion = await client.chat.completions.create({
model: "Premedice/Premed-4",
messages: [
{ role: "user", content: "What is the CHA2DS2-VASc score for a patient with AF, age 72, hypertension, and diabetes?" }
],
});
console.log(completion.choices[0].message.content);
Response
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1721846400,
"model": "Premedice/Premed-4",
"choices": [
{
"index": 0,
"finish_reason": "stop",
"message": {
"role": "assistant",
"content": "For this patient with atrial fibrillation, age 72, hypertension, and diabetes, the CHA\u2082DS\u2082-VASc score is **5**:\n\n- **C**hronic heart failure: 0\n- **H**ypertension: 1\n- **A**ge \u226575: 0\n- **D**iabetes: 1\n- **S**troke/TIA/thromboembolism: 0\n- **V**ascular disease: 0\n- **A**ge 65-74: 1\n- **Sc**ex category (female): 1\n\nA score of 5 indicates high stroke risk. Oral anticoagulation is strongly recommended per current guidelines (ESC 2020, AHA/ACC 2023) [PubMed:32386591].\n\n**Safety note:** Confirm no contraindications to anticoagulation (active bleeding, severe renal/hepatic impairment) before initiating therapy."
}
}
],
"usage": {
"prompt_tokens": 127,
"completion_tokens": 245,
"total_tokens": 372
}
}
Streaming
Streaming is enabled by default. Set "stream": false to disable. Each chunk follows the OpenAI streaming format:
data: {"id":"chatcmpl-abc","object":"chat.completion.chunk","created":1721846400,"model":"Premedice/Premed-4","choices":[{"index":0,"delta":{"role":"assistant","content":"For"},"finish_reason":null}]}
data: {"id":"chatcmpl-abc","object":"chat.completion.chunk","created":1721846400,"model":"Premedice/Premed-4","choices":[{"index":0,"delta":{"content":" this"},"finish_reason":null}]}
data: {"id":"chatcmpl-abc","object":"chat.completion.chunk","created":1721846400,"model":"Premedice/Premed-4","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}
data: [DONE]
Which AI models are available through the Premedice API?
The API exposes a single model name. Your subscription plan determines which backend variant handles your requests.
Response
{
"object": "list",
"data": [
{
"id": "Premedice/Premed-4",
"object": "model",
"created": 1721846400,
"owned_by": "premedice"
}
]
}
Backend Variants
Your subscription plan determines which backend model processes your requests. The API always returns Premedice/Premed-4 as the model name.
| Variant | Backend Model | Best For |
|---|---|---|
| High | Premed 4 High | Fastest responses, general medical Q&A |
| Mid | Premed 4 Mid | Balanced depth and speed |
| Low | Premed 4 Low | Long outputs, budget-conscious usage |
What medical tools are included in the Premedice API?
23 built-in medical tools are automatically available to the AI during chat completions.
| Tool | Description |
|---|---|
| PubMed | Search biomedical literature via NCBI PubMed |
| OpenFDA | Drug information, adverse events, and label data from the FDA |
| RxNorm | Drug names, ingredients, and dosage forms |
| DailyMed | Official FDA drug labeling and package inserts |
| ClinicalTrials.gov | Search ongoing and completed clinical trials |
| Semantic Scholar | Academic paper search with citation context |
| Europe PMC | Life sciences and biomedical literature |
| Premedice skills | Discover and execute app skills (search_skills, read_skill, list_skills, execute_app_skill) |
The full tool set is 23: medical_plan, pubmed_search, openfda_search, rxnorm_search, dailymed_search, clinical_trials_search, semantic_scholar, europe_pmc_search, open_targets_search, chembl_search, pubchem_search, pharmgkb_search, npi_lookup, nutrition_lookup, drug_interaction_check, clinical_calculator, medical_code_lookup, mental_health_screen, vaccine_schedule_check, search_skills, read_skill, list_skills, execute_app_skill.
How do I interpret labs and verify evidence?
Two clinic-facing endpoints on the same auth, rate-limit, and billing rails as chat. Both are also exposed as MCP tools.
Lab Interpretation
Interprets a structured panel with the full pipeline and returns out-of-range findings, likely meaning, red flags, next steps, and not established where the data are insufficient. Billing matches /v1/chat/completions.
| Field | Type | Required | Description |
|---|---|---|---|
labs | array | Yes | 1–80 results. Each entry needs analyte (≤80 chars); value is a number or a string ≤40 chars; unit ≤30 chars. Optional: reference_low, reference_high, flag, collected_at. |
question | string | No | Optional clinical question about the panel. |
patient_context | object | No | Optional patient context; enables the standard safety checks. |
variant | string | No | low, mid, or high. Default auto-routes by plan. |
curl https://api.premedice.com/v1/labs/interpret \
-H "Authorization: Bearer pm_live_abc123..." \
-H "Content-Type: application/json" \
-d '{
"labs": [
{ "analyte": "Potassium", "value": 6.1, "unit": "mEq/L", "reference_low": 3.5, "reference_high": 5.0 },
{ "analyte": "Creatinine", "value": 2.4, "unit": "mg/dL", "reference_low": 0.6, "reference_high": 1.2 }
],
"question": "Any urgent action needed before clinic opens?",
"patient_context": { "age": 71, "sex": "male", "medications": ["lisinopril"] }
}'
Lab Response
{
"id": "req_abc123",
"object": "chat.completion",
"created": 1761912000,
"model": "Premedice/Premed-4",
"choices": [{
"index": 0,
"finish_reason": "stop",
"message": { "role": "assistant", "content": "..." }
}],
"usage": { "prompt_tokens": 812, "completion_tokens": 640, "total_tokens": 1452 },
"premedice": {
"sources": [{ "type": "pubmed", "id": "12345", "title": "...", "url": "https://pubmed.ncbi.nlm.nih.gov/12345/" }],
"safety_flags": [{ "type": "lab_alert", "severity": "critical", "message": "potassium 6.1 mEq/L is critically high (3.5-5 mEq/L)." }],
"modes": ["consult", "clinical", "research"]
}
}
Evidence Verification
Checks a clinical claim against the sources you supply, using z-ai/glm-5.3-flash with an 8-second timeout. Not billed in v1. If the verifier is unavailable, times out, or returns unparseable output, the endpoint fails open with checked: false.
| Field | Type | Required | Description |
|---|---|---|---|
claim | string | Yes | 1–2000 characters. |
sources | array | No | 0–30 objects with optional title, url, source_type, and id. |
curl https://api.premedice.com/v1/evidence/verify \
-H "Authorization: Bearer pm_live_abc123..." \
-H "Content-Type: application/json" \
-d '{
"claim": "ACE inhibitors reduce mortality in HFrEF.",
"sources": [{
"title": "2022 AHA/ACC/HFSA Heart Failure Guideline",
"url": "https://www.ahajournals.org/doi/10.1161/CIR.0000000000001063",
"source_type": "guideline"
}]
}'
Evidence Response
{
"claim": "ACE inhibitors reduce mortality in HFrEF.",
"verification": {
"supported": true,
"confidence": "high",
"unsupported_parts": [],
"missing_evidence": [],
"notes": "The cited guideline directly recommends ACE inhibitors for HFrEF to reduce mortality."
},
"checked": true
}
MCP tools
| Tool | Description |
|---|---|
lab_interpret | Same validation and billing as /v1/labs/interpret. |
evidence_verify | Same logic as /v1/evidence/verify; free in v1. |
Both are available through POST /mcp alongside premedice_chat and the medical search tools.
How much does the Premedice API cost?
Per-token billing. Costs are debited from your Premedice token balance.
All prices in USD. Costs are debited from your Premedice token balance. Your subscription plan (Pro or Advanced) includes a monthly token allocation.
What error codes does the Premedice API return?
Standard HTTP status codes with error details.
| Status | Type | Cause |
|---|---|---|
400 | Invalid request | Missing messages, invalid JSON, or request too large |
401 | Unauthorized | Missing, invalid, or revoked API key |
402 | Payment required | Free account or insufficient credits |
429 | Rate limited | Too many requests per minute |
502 | Upstream error | Model provider returned an error. Retry the request. |
Error Response Format
{
"error": {
"message": "Invalid or revoked API key",
"type": "premedice_error",
"code": 401,
"request_id": "req_abc123..."
}
}
Frequently Asked Questions
Common questions about the Premedice medical AI API.
The Premedice API is an OpenAI-compatible medical AI endpoint. It provides chat completions with built-in medical research tools (PubMed, OpenFDA, RxNorm, ClinicalTrials.gov), per-token billing, and works with any OpenAI SDK, Cursor, Continue.dev, or opencode. It is a drop-in replacement for the OpenAI API for healthcare and medical AI use cases.
Generate an API key from your Premedice dashboard at app.premedice.com/dashboard/settings/api-keys. You need an active paid subscription (Pro or Advanced). Free accounts cannot use the API. Keys start with pm_live_.
The API exposes a single model name, Premedice/Premed-4, which internally routes to one of three tiers based on your subscription: High (fastest responses), Mid (balanced performance), or Low (lowest cost). All variants are OpenAI-compatible with automatic fallback.
The API includes 23 built-in medical tools: medical planning, PubMed search, OpenFDA drug information, RxNorm drug lookup, DailyMed labeling, ClinicalTrials.gov search, Semantic Scholar, Europe PMC, Open Targets, ChEMBL, PubChem, PharmGKB, NPI lookup, nutrition lookup, drug interaction checks, clinical calculators, medical code lookup, mental health screening, vaccine schedules, and the Premedice skill catalog (search_skills, read_skill, list_skills, execute_app_skill). These tools are automatically available to the AI model during chat completions.
The API uses per-token billing. You are charged based on input and output tokens consumed per request. Pricing varies by variant: High (input: $6/1M tokens, output: $30/1M tokens), Mid (input: $5/1M tokens, output: $15/1M tokens), Low (input: $1.20/1M tokens, output: $10/1M tokens). Costs are debited from your Premedice token balance.
The Premedice API runs over HTTPS and logs request metadata (tokens, cost, latency, status) for usage and billing. It does not claim HIPAA compliance on its own; a compliant deployment requires a business associate agreement and configuration appropriate to your use case. Consult your compliance team before sending protected health information.
Yes. The Premedice API is fully OpenAI-compatible. Use it as a drop-in replacement by setting baseURL to https://api.premedice.com/v1 and using your Premedice API key. It works with the official OpenAI Python and Node.js SDKs, as well as Cursor, Continue.dev, opencode, LiteLLM, and Portkey.
The service allows 20 requests per 60 seconds per API key for chat, labs, evidence, and MCP tools/call. Handshakes and tool listings do not count. There is no daily token cap enforced by the API service; credits are the gate.