Premedice / API Docs
Get API Key
Live API

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
01 — Authentication

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

HTTP
Authorization: Bearer pm_live_abc123...
⚠
Requirements: You must have an active paid Premedice subscription and sufficient credits. Free accounts cannot use the API.

Rate Limits

LimitValueNotes
Requests20 per 60 secondsPer API key, for chat, labs, evidence, and MCP tools/call. Handshakes and listings do not count.
Daily token capNone enforcedCredits are the gate.

These are configured limits, not measured throughput. No latency, error-rate, uptime, or SLA figure is published.

02 — Quick Connect

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:

Step 1 — Run the connect command
Terminal
/connect

Select OpenAI compatible from the provider list, then enter:

Config
Base URL:  https://api.premedice.com/v1
API Key:   pm_live_your_key_here
Model:     Premedice/Premed-4
Step 2 — Or add to your opencode.json directly

Create or edit opencode.json in your project root:

JSON
{
  "$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
          }
        }
      }
    }
  }
}
✓
That's it. opencode will now route all messages through the API with enhanced research capabilities automatically enabled. No extra configuration needed.

Cursor

Add Premedice as a custom model in Cursor:

1. Open Settings → Models

2. Under "OpenAI API Key", click the gear icon and add:

Config
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

ℹ
Cursor tip: Use this API for specialized tasks that benefit from enhanced research capabilities. Keep your regular model for general coding tasks. You can switch models per conversation.

Continue.dev

Add to your ~/.continue/config.yaml:

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:

JSON
{
  "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)

Python
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)
JavaScript
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);
03 — Chat Completions

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.

POST /v1/chat/completions
ℹ
Machine-readable spec. The OpenAPI 3.1 document for these endpoints is at /openapi.json.

Request Body

FieldTypeRequiredDescription
modelstringNoPremedice/Premed-4 (default; auto-routes by plan). low, mid, or high force a tier the plan allows.
messagesarrayYesArray of message objects with role and content
streambooleanNoEnable SSE streaming (default: true)
temperaturenumberNoSampling temperature 0–2 (default: 0.3)
max_tokensintegerNoMax output tokens (default: 4096)
top_pnumberNoNucleus sampling parameter
stopstring|arrayNoStop sequences
userstringNoUnique user identifier for abuse tracking

Messages Format

JSON
{
  "messages": [
    { "role": "system", "content": "You are a helpful assistant." },
    { "role": "user", "content": "What are the first-line treatments for hypertension?" }
  ]
}
ℹ
Enhanced responses. The API provides enriched, well-sourced answers with automatic research capabilities and 23 built-in medical tools. No extra configuration needed.

Examples

cURL
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?"}
    ]
  }'
Python
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"])
JavaScript
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);
OpenAI SDK
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

JSON
{
  "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:

SSE
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]
04 — Models

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.

GET /v1/models

Response

JSON
{
  "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.

VariantBackend ModelBest For
HighPremed 4 HighFastest responses, general medical Q&A
MidPremed 4 MidBalanced depth and speed
LowPremed 4 LowLong outputs, budget-conscious usage
ℹ
Automatic fallback. If the primary model fails, the API automatically retries with fallback models. No configuration needed.
05 — Tools

What medical tools are included in the Premedice API?

23 built-in medical tools are automatically available to the AI during chat completions.

ToolDescription
PubMedSearch biomedical literature via NCBI PubMed
OpenFDADrug information, adverse events, and label data from the FDA
RxNormDrug names, ingredients, and dosage forms
DailyMedOfficial FDA drug labeling and package inserts
ClinicalTrials.govSearch ongoing and completed clinical trials
Semantic ScholarAcademic paper search with citation context
Europe PMCLife sciences and biomedical literature
Premedice skillsDiscover 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.

ℹ
Automatic tool use. The AI model decides when to invoke tools based on the user's question. No configuration needed — tools are preloaded in every request.
06 — Labs & Evidence

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

POST /v1/labs/interpret

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.

FieldTypeRequiredDescription
labsarrayYes1–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.
questionstringNoOptional clinical question about the panel.
patient_contextobjectNoOptional patient context; enables the standard safety checks.
variantstringNolow, mid, or high. Default auto-routes by plan.
cURL
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

JSON
{
  "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"]
  }
}
ℹ
Deterministic fallback. If the model returns no content, the API returns a rule-based summary of the supplied values instead of an empty answer. The fallback never invents reference ranges or diagnoses.

Evidence Verification

POST /v1/evidence/verify

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.

FieldTypeRequiredDescription
claimstringYes1–2000 characters.
sourcesarrayNo0–30 objects with optional title, url, source_type, and id.
cURL
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

JSON
{
  "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

ToolDescription
lab_interpretSame validation and billing as /v1/labs/interpret.
evidence_verifySame logic as /v1/evidence/verify; free in v1.

Both are available through POST /mcp alongside premedice_chat and the medical search tools.

07 — Pricing

How much does the Premedice API cost?

Per-token billing. Costs are debited from your Premedice token balance.

Low
Premed 4 Low
Input $1.20 / 1M
Output $10.00 / 1M
Mid
Premed 4 Mid
Input $5.00 / 1M
Output $15.00 / 1M

All prices in USD. Costs are debited from your Premedice token balance. Your subscription plan (Pro or Advanced) includes a monthly token allocation.

08 — Errors

What error codes does the Premedice API return?

Standard HTTP status codes with error details.

StatusTypeCause
400Invalid requestMissing messages, invalid JSON, or request too large
401UnauthorizedMissing, invalid, or revoked API key
402Payment requiredFree account or insufficient credits
429Rate limitedToo many requests per minute
502Upstream errorModel provider returned an error. Retry the request.

Error Response Format

JSON
{
  "error": {
    "message": "Invalid or revoked API key",
    "type": "premedice_error",
    "code": 401,
    "request_id": "req_abc123..."
  }
}
09 — FAQ

Frequently Asked Questions

Common questions about the Premedice medical AI API.

What is the Premedice 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.

How do I get an API key? ▾

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_.

Which AI models are available? ▾

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.

What medical tools are included? ▾

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.

How does billing work? ▾

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.

Is the API HIPAA compliant? ▾

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.

Can I use it with OpenAI SDK? ▾

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.

What are the rate limits? ▾

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.