Chat Completions
Create a chat completion using your configured AI provider.
Endpoint
POST /v1/chat/completions
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model ID (e.g., gpt-4, claude-3-opus, gemini-pro) |
messages | array | Yes | Array of message objects |
temperature | number | No | Sampling temperature (0-2). Default: 1 |
max_tokens | number | No | Maximum tokens to generate |
top_p | number | No | Nucleus sampling parameter |
stream | boolean | No | Enable streaming responses |
stop | string/array | No | Stop sequences |
Message Object
| Parameter | Type | Required | Description |
|---|---|---|---|
role | string | Yes | system, user, or assistant |
content | string | Yes | The message content |
Example Request
curl https://api.scrub.health/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_SCRUB_API_KEY" \
-d '{
"model": "gpt-4",
"messages": [
{
"role": "system",
"content": "You are a helpful medical assistant."
},
{
"role": "user",
"content": "What are common symptoms of the flu?"
}
],
"temperature": 0.7,
"max_tokens": 500
}'
Example Response
{
"id": "chatcmpl-abc123def456",
"object": "chat.completion",
"created": 1705123456,
"model": "gpt-4",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Common symptoms of the flu include:\n\n1. **Fever** - Usually high (100-104°F)\n2. **Body aches** - Muscle and joint pain\n3. **Fatigue** - Extreme tiredness\n4. **Cough** - Usually dry\n5. **Headache** - Often severe\n6. **Chills and sweats**\n7. **Sore throat**\n8. **Runny or stuffy nose**\n\nSymptoms typically appear 1-4 days after exposure and can last 1-2 weeks."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 28,
"completion_tokens": 112,
"total_tokens": 140
}
}
Model Mapping
Scrub automatically routes requests to your configured provider. You can use any of these model identifiers:
OpenAI Models
gpt-4,gpt-4-turbo,gpt-4ogpt-3.5-turbo
Anthropic Models
claude-3-opus,claude-3-sonnet,claude-3-haikuclaude-3-5-sonnet
Google Models
gemini-pro,gemini-1.5-pro,gemini-1.5-flash
Streaming
To enable streaming responses, set stream: true:
curl https://api.scrub.health/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_SCRUB_API_KEY" \
-d '{
"model": "gpt-4",
"messages": [{"role": "user", "content": "Hello"}],
"stream": true
}'
Streaming responses use Server-Sent Events (SSE) format.