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
| Plan | Requests / min | Monthly Tokens |
|---|---|---|
| Pro | 60 | Included in plan |
| Advanced | 120 | Included in plan |
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.
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Premedice/Premed-4 |
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?
15 built-in medical research 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 |
| create_file | Generate files from AI responses |
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 15 built-in medical tools: PubMed search, OpenFDA drug information, RxNorm drug lookup, DailyMed labeling, ClinicalTrials.gov search, Semantic Scholar academic search, Europe PMC search, and a create_file tool. 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 is designed with healthcare data privacy in mind. It uses end-to-end encryption, does not store conversation data beyond the request lifecycle, and follows HIPAA-aligned practices. However, you should consult your compliance team to determine if the API meets your specific regulatory requirements.
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.
Rate limits depend on your subscription plan. Pro plan: 60 requests per minute. Advanced plan: 120 requests per minute. Monthly token limits are included in your plan.