Vaidya.ai

Authentication

Get your API key and start making authenticated requests in under a minute.

How it works

Every request needs an API key passed as a Bearer token. No OAuth, no session tokens — just a single header.

1. Get your key

  1. Sign in at console.vaidya.ai.
  2. Go to API Keys.
  3. Click Create API Key.
  4. Copy the key and store it somewhere safe — you won't see it again.

2. Add it to your requests

Include the key in the Authorization header:

Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

Quick examples

import os, requests, json

response = requests.post(
    "https://api.vaidya-dev.fractal.ai/chat/completions",
    headers={
        "Authorization": f"Bearer {os.environ['VAIDYA_API_KEY']}",
        "Content-Type": "application/json",
    },
    data=json.dumps({
        "model": "Vaidya-v2",
        "case": "drug_lookup",
        "messages": [
            {"role": "user", "content": "Can I take cetirizine with montelukast?"}
        ],
        "max_tokens": 200,
        "temperature": 0.2,
    }),
    timeout=60,
)

print(response.json())
curl --request POST \
  --url https://api.vaidya-dev.fractal.ai/chat/completions \
  --header "authorization: Bearer $VAIDYA_API_KEY" \
  --header "content-type: application/json" \
  --data '{
    "model": "Vaidya-v2",
    "case": "symptom_qa",
    "messages": [
      {"role": "user", "content": "Sore throat and mild fever since yesterday."}
    ],
    "max_tokens": 300,
    "temperature": 0.3
  }'
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["VAIDYA_API_KEY"],
    base_url="https://api.vaidya-dev.fractal.ai",
)

resp = client.chat.completions.create(
    model="Vaidya-v2",
    messages=[{"role": "user", "content": "Can I take cetirizine with montelukast?"}],
    extra_body={"case": "drug_lookup"},
    max_tokens=200,
    temperature=0.2,
)

print(resp.choices[0].message.content)

Keep your key safe

Never hardcode API keys in client-side code or commit them to version control.

Set an environment variable instead:

export VAIDYA_API_KEY="sk-..."

Then read it at runtime:

import os
API_KEY = os.environ["VAIDYA_API_KEY"]

Tips:

  • Use a secrets manager (Vault, AWS Secrets Manager, etc.) in production.
  • Rotate keys immediately if exposed.
  • Use separate keys for dev, staging, and prod.

Error reference

StatusCodeWhat happenedWhat to do
401invalid_api_keyKey is missing or wrongDouble-check the Authorization header
401expired_api_keyKey was revoked or expiredGenerate a new one in the console
403insufficient_permissionsKey doesn't have accessCheck your project/account permissions
429rate_limit_exceededToo many requestsBack off and retry (honor Retry-After if present)

On this page