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

PlanRequests / minMonthly Tokens
Pro60Included in plan
Advanced120Included in plan
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

Request Body

FieldTypeRequiredDescription
modelstringYesPremedice/Premed-4
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 15 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?

15 built-in medical research 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
create_fileGenerate files from AI responses
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 — 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.

07 — 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..."
  }
}
08 — 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 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.

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

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?

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.