Providers
OpenAI Integration
Complete guide to using OpenAI with Bastio for GPT-5, GPT-4o, and o1 models.
OpenAI Integration
Use OpenAI's models through their official API while maintaining Bastio's security protection.
Overview
Bastio offers full support for OpenAI models, allowing you to:
- Access latest models - GPT-5, GPT-4o, o1-preview, and more
- Seamless integration - Drop-in replacement for OpenAI SDKs
- Full security coverage - All Bastio security features work with OpenAI
- Cost control - Track usage and set limits
Supported Models
Bastio supports all current OpenAI models:
| Model | Context | Input/Output Price |
|---|---|---|
| GPT-5.1 | 272K | $1.25/$10.00 per 1M tokens |
| GPT-5 | 272K | $1.25/$10.00 per 1M tokens |
| GPT-5 Mini | 272K | $0.25/$2.00 per 1M tokens |
| GPT-4o | 128K | $2.50/$10.00 per 1M tokens |
| GPT-4o Mini | 128K | $0.15/$0.60 per 1M tokens |
| o1-preview | 128K | $15.00/$60.00 per 1M tokens |
| o1-mini | 128K | $3.00/$12.00 per 1M tokens |
Quick Start
Prerequisites
- OpenAI API Key
- OpenAI account with credits
Step 1: Get Credentials
- Go to OpenAI Platform
- Create a new secret key
- Save it securely
Configuration
Via Dashboard
- Go to Dashboard → Proxies → Create New Proxy
- Select OpenAI as provider
- Enter your OpenAI API key
Via API
# Create OpenAI proxy
curl -X POST https://api.bastio.ai/proxy \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Production OpenAI",
"provider": "openai",
"llm_mode": "byok",
"model_behavior": "passthrough"
}'
# Add API Key
curl -X POST https://api.bastio.ai/keys/provider \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"provider": "openai",
"key_name": "OpenAI Production",
"api_key": "sk-..."
}'Making Requests
Bastio is a drop-in replacement for the OpenAI API. Just change the baseURL and apiKey.
Python Example
from openai import OpenAI
client = OpenAI(
base_url="https://api.bastio.ai/v1/guard/{PROXY_ID}/v1",
api_key="your-bastio-api-key"
)
response = client.chat.completions.create(
model="gpt-5.1",
messages=[
{"role": "user", "content": "Explain quantum computing"}
]
)
print(response.choices[0].message.content)JavaScript Example
import OpenAI from 'openai';
const client = new OpenAI({
baseURL: 'https://api.bastio.ai/v1/guard/{PROXY_ID}/v1',
apiKey: process.env.BASTIO_API_KEY,
});
const response = await client.chat.completions.create({
model: 'gpt-5.1',
messages: [
{ role: 'user', content: 'Hello from OpenAI!' }
],
});
console.log(response.choices[0].message.content);Streaming Example
stream = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Write a poem"}],
stream=True
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)Features & Limitations
Supported Features
- Chat Completions: Full support
- Streaming: Real-time token streaming
- Function Calling: Support for tools and function calling
- Vision: Multimodal support (GPT-4o, GPT-5)
- JSON Mode: Structured output support
Vision Example
response = client.chat.completions.create(
model="gpt-4o",
messages=[
{
"role": "user",
"content": [
{"type": "text", "text": "What's in this image?"},
{
"type": "image_url",
"image_url": {
"url": "https://example.com/image.jpg"
}
}
]
}
]
)Troubleshooting
Invalid API Key
Error: 401 Unauthorized or Incorrect API key provided
Solution: Check that your OpenAI key is correct and active.
Quota Exceeded
Error: 429 Too Many Requests or You exceeded your current quota
Solution: Check your OpenAI billing settings and credit balance.