Skip to main content

Doximity Ask API

Evidence-based clinical answers for your product, server to server

Overview

The Ask API gives your application's backend direct, server-to-server access to Doximity Ask, the clinician-facing AI answer engine built on Doximity's verified healthcare professional network. Send a clinical question and receive an evidence-based answer with citations, drug dose lookups, and structured artifacts.

This API is designed for enterprise integrations — EMR workflows, clinical communication tools, and care coordination products — where your backend acts on behalf of your organization. No Doximity user signs in: your service authenticates itself with the OAuth 2.0 Client Credentials grant, and usage is attributed to your organization.

This page covers the core mechanics of how to call the API and what to expect back, for a full working demo see Ask API on Github.

Authentication

The Client Credentials flow

The Ask API uses the OAuth 2.0 Client Credentials grant. Because calls are made by your backend — not by a clinician in a browser — there is no redirect to the Doximity OAuth dialog and no end-user consent screen. Your service presents its client credentials directly and receives an access token it can use until expiry.

Before you begin, your organization needs a registered OAuth application with Doximity, provisioned with the client credentials grant and access to the Ask API. Reach out through the Get started page to request access. You'll receive a client ID and a client secret. Treat the secret like a password: keep it out of source control, and never expose it to clients or end users.

Step 1: Dynamically fetch the configuration files

We implement OpenID Connect Discovery, so your application can discover the correct endpoints dynamically. Fetch the configuration document below — the same one used by the user-facing OAuth flow:

GET https://auth.doximity.com/.well-known/openid-configuration

The response includes the token endpoint your service will use:

{
  "issuer": "https://auth.doximity.com",
  "token_endpoint": "https://auth.doximity.com/oauth/token",
  ...
}

Cache this configuration and re-fetch it periodically rather than hard-coding the URLs.

Step 2: Request an access token

Exchange your client ID and client secret for an access token. Send the credentials in the request body:

POST https://auth.doximity.com/oauth/token
Content-Type: application/x-www-form-urlencoded

grant_type=client_credentials
client_id=YOUR_CLIENT_ID
client_secret=YOUR_CLIENT_SECRET

The authorization server responds with a bearer token:

{
  "access_token": "doxat_...",
  "token_type": "Bearer",
  "expires_in": 86400
}

Cache the token and reuse it until shortly before it expires — do not fetch a new token for every API call. When the token expires, simply request a new one the same way. If a request comes back 401, mint a fresh token and retry once.

Making a request

Send an HTTPS POST to the Ask endpoint with your bearer token. The request body is JSON, following the OpenAI chat completions message format:

POST https://docs-gpt.doximity.com/api/v1/external_chat_completions
Authorization: Bearer YOUR_ACCESS_TOKEN
Content-Type: application/json

{
  "messages": [
    {"role": "user", "content": "What is the first-line treatment for hypertension in a 55 year old with no comorbidities?"}
  ],
  "stream": true
}

Request parameters

ParameterRequiredDescription
messagesyesThe conversation so far, as an array ofobjects in OpenAI chat format. Roles:userandassistant. To continue a multi-turn conversation, include the prior turns followed by the new user turn.
streamnoSet totrueto receive the answer as a server-sent events stream (recommended for interactive products). Defaults tofalse, which returns a single JSON response. SeeStreamingandBlocking responsesbelow.
npinoThe NPI of the clinician on whose behalf this turn is made (10-digit number). Used for usage attribution and reporting only — it does not change the answer.

Model selection, sampling settings, and tool configuration are managed by Doximity and cannot be changed per request. Responses always report the model as "clinical_reference".

Streaming responses

With "stream": true, the API responds with text/event-stream — the same server-sent events format as OpenAI's streaming chat completions. A turn arrives as five kinds of frames:

FrameWhat it carries
reasoning_contentShort reasoning summaries ("narration cards") streamed while the assistant researches the question — one every second or so, starting within a second of the request. Show them to clinicians as progress indication. They stop once the answer starts.
contentThe answer itself, as incremental text. Claims are cited inline as numbered markdown links — e.g.(#ref-abc12345)— seeCitationsbelow.
event: citationEach source the answer cites, as its own frame: the source'stitle,url,pmid,journal, andyear, thepassagethe answer was written from, and thenumberits link shows — seeCitationsbelow.
event: artifactStructured results that accompany the answer: validated drug dose and interaction lookups, dose-check verdicts, and generated images. Each arrives as its own event with a JSON payload — seeArtifactsfor the full catalog.
finish_reasonThe answer's own chunks never carryfinish_reason. A final chunk with"finish_reason": "stop"ends the stream once the answer and every artifact and citation frame have been sent; thedata: [DONE]sentinel follows.

A typical stream looks like:

data: {"id":"thought-1","object":"chat.completion.chunk","model":"clinical_reference","choices":[{"index":0,"delta":{"role":"assistant","reasoning_content":"**Identifying first-line therapy for hypertension**"},"finish_reason":null}]}

data: {"id":"chatcmpl-1","object":"chat.completion.chunk","model":"clinical_reference","choices":[{"index":0,"delta":{"role":"assistant","content":"First-line treatment for hypertension is a thiazide-like diuretic [1](#ref-nMUXQwYk), an ACE inhibitor, ..."},"finish_reason":null}]}

event: citation
data: {"id":"nMUXQwYk","object":"chat.completion.citation","number":1,"title":"2017 ACC/AHA Guideline for High Blood Pressure","url":"https://...","pmid":"12345678","journal":"JACC","year":2018,"passage":"...","created":1730000000,"model":"clinical_reference"}

data: {"id":"chatcmpl-1","object":"chat.completion.chunk","model":"clinical_reference","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}

data: [DONE]

Structured results — validated drug dose and interaction lookups, dose-check verdicts, and generated images — are delivered as artifact events interleaved with the stream. A dose card arrives once the answer cites its source; an interaction card the answer doesn't cite, and the dose-check verdicts, follow the answer. Each frame carries the artifact's envelope (the same shape as the blocking response's artifacts array) plus created and model:

event: artifact
data: {"id":"art_dose_01","object":"chat.completion.artifact","schema_version":2,"type":"drug_dose","data":{"drug":{"id":"drug_examplemed","name":"Examplemed"},"regimens":[{"text":"100 mg PO daily","kind":"dose","amount":{"amount":100},"unit":"mg","route":"PO","frequency":"daily"}],"sources":[{"citation_id":"nMUXQwYk","section":"Dosage and administration"}]},"created":1730000000,"model":"clinical_reference"}

Test streaming interactively with curl -N (disable buffering):

curl -N https://docs-gpt.doximity.com/api/v1/external_chat_completions \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"messages":[{"role":"user","content":"What is the first-line treatment for hypertension?"}],"stream":true}'

Blocking responses

With "stream": false (the default), the API returns a single JSON chat completion. A turn takes one to two minutes — these answers are thorough, evidence-based, and written for clinicians — so the request will be long-lived.

The response body contains:

FieldDescription
id, object, created, modelOpenAI identity fields.modelis always"clinical_reference".
choices[0].message.contentThe full answer, including the inline citation markers (seeCitations).
choices[0].finish_reason"stop"when the answer completed.
usageToken counts for the turn (prompt, completion, total).
artifactsArray of structured artifacts the turn produced — validated drug dose and interaction lookups, dose-check verdicts, generated images. Empty when the turn produced none. SeeArtifactsfor the payload catalog.
citationsThe sources the answer cites, keyed by the same anchor ids as the inline markers (seeCitations). Sources only an artifact names ride along, unnumbered. Present when the turn has sources to report.

A note on load balancers and idle timeouts: if the turn is still running after 15 seconds, the server commits the HTTP 200 status early and writes a single space character every 15 seconds until the JSON body is ready. JSON permits leading whitespace, so parse the body tolerantly (trim leading whitespace before JSON.parse) rather than assuming the first byte of the body is an opening brace. This keeps intermediaries that enforce idle timeouts — typically 60 seconds — from cutting the connection.

If the turn fails after the 200 was committed, the error is delivered as an error body on that same 200 response rather than as an HTTP error status.

Response format

The non-streaming response body is an OpenAI-compatible chat completion with two additional arrays — artifacts and citations:

{
  "id": "chatcmpl-9f3ac2",
  "object": "chat.completion",
  "created": 1730000000,
  "model": "clinical_reference",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "First-line treatment for hypertension is a thiazide-like diuretic [1](#ref-nMUXQwYk), an ACE inhibitor [2](#ref-iFr61uDs), ..."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 1234,
    "completion_tokens": 800,
    "total_tokens": 2034
  },
  "artifacts": [],
  "citations": [
    {"id": "nMUXQwYk", "object": "chat.completion.citation", "number": 1, "title": "2017 ACC/AHA Guideline for High Blood Pressure", "url": "https://...", "pmid": "12345678", "journal": "JACC", "year": 2018, "passage": "..."},
    {"id": "iFr61uDs", "object": "chat.completion.citation", "number": 2, "title": "...", "url": "https://...", "journal": "..."}
  ]
}

In streaming responses, the reasoning summaries are joined from the reasoning_content deltas, and the artifacts and citations are collected from their event: frames. The two subsections below describe the structured payloads in detail.

Citations

Answers cite their sources inline. The answer text carries numbered markdown links of the form (#ref-abc12345) — the number is the citation's position in the answer, and the #ref- anchor identifies the specific source. The markers appear exactly where the cited claim is made, so rendering the answer as markdown gives clinicians citation links in place.

Every source the answer cites is also delivered as structured data — a citations array on the blocking response, and an event: citation frame per source on a streamed response (same payload, plus created and model). Each entry is keyed by the same anchor id as the inline markers, and carries the source's title, url, pmid, journal, and year, the passage the answer was written from, and the number shown by the answer's link to it. To render a numbered bibliography, collect the citations and match each link's anchor (#ref-nMUXQwYk) to the entry with the matching id — or render each entry by its number.

Artifacts

An artifact is a typed, validated, structured result the turn produced alongside its answer — the data behind a rich card, not prose. Drug information arrives as artifacts rather than sentences so your client can render it consistently: dose tables, severity badges, images.

Every artifact shares one envelope:

{
  "id": "art_dose_01",
  "object": "chat.completion.artifact",
  "schema_version": 2,
  "type": "drug_dose",
  "data": { ... }
}

The payload in

data depends on type — there are four:
typedata payloadWhat a client does with it
drug_dosedrug({id, name});regimens— the source card's dose lines, each carried verbatim astext, with akind(doseormaximum) and the fields that line states:amountandamount_max(a range, e.g. 20–30),components(a combination product, e.g. 875/125),unit,route,frequency,conditions,duration,max_dose— each as the card writes it, and a field the line doesn't state is omitted, never guessed;note;sources— the backing citations ({citation_id, section})A validated dose card for the drug. Render each line'stextas written, or build a table from its parsed fields. Sent only when the answer cites its source.
drug_interactiondrugs— two or more {id, name};severity— one ofminor,moderate,major,contraindicated;effect;management(when the source states one);sourcesAn interaction warning. Every interaction the drug lookup returns is sent; one the answer doesn't cite arrives after the answer. Severity should drive your styling — acontraindicatedpair wants a stronger treatment than aminorone.
dose_checkall_verified(true when every checked statement verified);statements— each dose the answer states, as(offsets into the answer text),status— one ofverified,partial,unverified— and thereferencethat decided it: a cited source, bycitation_id, or a drug-library card, bytitleA verdict on each dose the answer states, checked against the passages the answer cites and then Doximity's drug library. Arrives after the answer, when it states a dose.
generated_imagemime_type(animage/*type);b64_json(base64-encoded image bytes)An image the assistant generated for the turn. Decodeb64_jsonand render it inline. Images never appear in thecontenttext — this artifact is the only way one arrives.

Artifact ids are stable within a turn; the answer's content text refers to them where relevant. On streamed responses each artifact also arrives as its own event: artifact frame (with created and model added to the envelope), so a client can render cards as they happen instead of waiting for the full turn.

Errors

Errors use conventional HTTP status codes with a JSON body:

  • 401 Unauthorized — the access token is missing, expired, or invalid. Mint a fresh token and retry once.
  • 403 Forbidden — the OAuth application is not provisioned for the Ask API. Contact your Doximity representative.
  • 400 Bad Request — the request is malformed: missing or empty messages, and similar.
  • 429 Too Many Requests — you are exceeding your request rate limit.
  • 5xx — an unexpected failure. These are safe to retry with backoff; use idempotency on your side (don't double-bill your users for a retried turn).

Rate limits

Requests will be limited to a maximum of 5 in parallel unless otherwise agreed.

For the API Terms of Use, branding guidelines, and terms of use see the main API documentation.

Usage attribution

Each turn is attributed to your organization (the organization your OAuth application belongs to) for usage reporting. Passing the npi parameter additionally attributes the turn to the individual clinician it was made for.

Questions about the Ask API?

bd@doximity.com