Skip to main content

OpenAI

Connect Scrub to OpenAI to use GPT-4 and other OpenAI models with PHI protection.

Setup

  1. Get an OpenAI API key from platform.openai.com
  2. Log in to your Scrub Dashboard
  3. Go to Providers and select OpenAI
  4. Paste your API key and save

Available Models

ModelDescription
gpt-4Most capable GPT-4 model
gpt-4-turboGPT-4 Turbo with 128k context
gpt-4oGPT-4o optimized model
gpt-3.5-turboFast and cost-effective

Example 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": "system", "content": "You are a helpful healthcare assistant."},
{"role": "user", "content": "What are the symptoms of hypertension?"}
],
"temperature": 0.7
}'

Using the OpenAI SDK

Since Scrub is OpenAI-compatible, you can use the official OpenAI SDK by changing the base URL:

from openai import OpenAI

client = OpenAI(
api_key="your_scrub_api_key",
base_url="https://api.scrub.health/v1"
)

response = client.chat.completions.create(
model="gpt-4",
messages=[
{"role": "user", "content": "Hello!"}
]
)

print(response.choices[0].message.content)
import OpenAI from 'openai';

const client = new OpenAI({
apiKey: process.env.SCRUB_API_KEY,
baseURL: 'https://api.scrub.health/v1',
});

const response = await client.chat.completions.create({
model: 'gpt-4',
messages: [{ role: 'user', content: 'Hello!' }],
});

console.log(response.choices[0].message.content);

Supported Parameters

Scrub passes through all standard OpenAI parameters:

  • temperature
  • max_tokens
  • top_p
  • frequency_penalty
  • presence_penalty
  • stop
  • stream
  • n

Streaming

Streaming is fully supported:

stream = client.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": "Tell me a story"}],
stream=True
)

for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")