OpenAI
Connect Scrub to OpenAI to use GPT-4 and other OpenAI models with PHI protection.
Setup
- Get an OpenAI API key from platform.openai.com
- Log in to your Scrub Dashboard
- Go to Providers and select OpenAI
- Paste your API key and save
Available Models
| Model | Description |
|---|---|
gpt-4 | Most capable GPT-4 model |
gpt-4-turbo | GPT-4 Turbo with 128k context |
gpt-4o | GPT-4o optimized model |
gpt-3.5-turbo | Fast 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:
temperaturemax_tokenstop_pfrequency_penaltypresence_penaltystopstreamn
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="")