Skip to main content

cURL Examples

Examples using cURL to interact with the Scrub API.

Basic Request

curl https://api.scrub.health/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $SCRUB_API_KEY" \
-d '{
"model": "gpt-4",
"messages": [
{"role": "user", "content": "What are common symptoms of the flu?"}
]
}'

With System Message

curl https://api.scrub.health/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $SCRUB_API_KEY" \
-d '{
"model": "gpt-4",
"messages": [
{"role": "system", "content": "You are a helpful healthcare assistant. Provide accurate medical information."},
{"role": "user", "content": "What are the risk factors for heart disease?"}
],
"temperature": 0.7
}'

Multi-turn Conversation

curl https://api.scrub.health/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $SCRUB_API_KEY" \
-d '{
"model": "gpt-4",
"messages": [
{"role": "system", "content": "You are a medical assistant."},
{"role": "user", "content": "What is hypertension?"},
{"role": "assistant", "content": "Hypertension, or high blood pressure, is a condition where the force of blood against artery walls is consistently too high."},
{"role": "user", "content": "What are the treatment options?"}
]
}'

Using Different Providers

Anthropic (Claude)

curl https://api.scrub.health/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $SCRUB_API_KEY" \
-d '{
"model": "claude-3-sonnet",
"messages": [
{"role": "user", "content": "Explain diabetes in simple terms."}
],
"max_tokens": 500
}'

Google (Gemini)

curl https://api.scrub.health/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $SCRUB_API_KEY" \
-d '{
"model": "gemini-1.5-pro",
"messages": [
{"role": "user", "content": "What is preventive care?"}
]
}'

Streaming Response

curl https://api.scrub.health/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $SCRUB_API_KEY" \
-d '{
"model": "gpt-4",
"messages": [
{"role": "user", "content": "List 5 healthy habits."}
],
"stream": true
}'

Checking PHI Detection Headers

Use -i to see response headers including PHI detection status:

curl -i https://api.scrub.health/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $SCRUB_API_KEY" \
-d '{
"model": "gpt-4",
"messages": [
{"role": "user", "content": "Hello, how can you help?"}
]
}'

Response headers will include:

X-Scrub-PHI-Detected: false
X-Scrub-Request-Id: req_abc123

Environment Variable Setup

Set your API key as an environment variable:

# Add to your .bashrc or .zshrc
export SCRUB_API_KEY="sk_scrub_your_api_key_here"

Then use $SCRUB_API_KEY in your requests as shown above.