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
- Sign in at console.vaidya.ai.
- Go to API Keys.
- Click Create API Key.
- 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/jsonQuick 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
| Status | Code | What happened | What to do |
|---|---|---|---|
| 401 | invalid_api_key | Key is missing or wrong | Double-check the Authorization header |
| 401 | expired_api_key | Key was revoked or expired | Generate a new one in the console |
| 403 | insufficient_permissions | Key doesn't have access | Check your project/account permissions |
| 429 | rate_limit_exceeded | Too many requests | Back off and retry (honor Retry-After if present) |

