Quick Start
Connect to Aize API in 2 minutes
Quick Start
Aize is fully OpenAI-compatible. Point your SDK to https://api.aize.dev/v1, keep the same request shape, and reuse your existing code.
Authentication
All API requests require authentication using your API key.
Authorization: Bearer YOUR_API_KEY
Content-Type: application/jsonUsing the OpenAI SDK
The easiest way to integrate is using the official OpenAI SDKs.
Python
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.aize.dev/v1"
)
response = client.chat.completions.create(
model="gpt-4o",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello! Can you help me?"}
]
)
print(response.choices[0].message.content)TypeScript / JavaScript
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: 'YOUR_API_KEY',
baseURL: 'https://api.aize.dev/v1',
});
async function main() {
const response = await client.chat.completions.create({
model: 'gpt-4o',
messages: [
{ role: 'system', content: 'You are a helpful assistant.' },
{ role: 'user', content: 'Hello! Can you help me?' }
]
});
console.log(response.choices[0].message.content);
}
main();Using the API Directly
You can use raw HTTP requests to interact with the API.
curl https://api.aize.dev/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "gpt-4o",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Hello! Can you help me?"
}
]
}'Streaming Responses
We support server-side events (SSE) for real-time streaming.
Python Streaming
stream = client.chat.completions.create(
model="gpt-4o",
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="")cURL Streaming
curl -N https://api.aize.dev/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "gpt-4o",
"stream": true,
"messages": [{"role":"user","content":"Stream a 2-line poem"}]
}'Advanced Usage
JSON Mode
Force the model to output valid JSON.
const completion = await client.chat.completions.create({
model: "gpt-4o",
response_format: { type: "json_object" },
messages: [{ role: "user", content: "Give a todo list as JSON" }],
});Function Calling (Tools)
Connect external tools and functions.
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "What's the weather in SF?"}],
tools=[{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the current weather",
"parameters": {
"type": "object",
"properties": {"location": {"type": "string"}}
}
}
}]
)
tool_calls = response.choices[0].message.tool_callsVision
Analyze images using compatible models.
curl https://api.aize.dev/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"messages": [{
"role": "user",
"content": [
{"type":"text","text":"What is in this image?"},
{"type":"image_url","image_url":{"url":"https://example.com/cat.jpg"}}
]
}]
}'Embeddings
Generate text embeddings for semantic search or clustering.
curl https://api.aize.dev/v1/embeddings \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "text-embedding-3-small",
"input": "The quick brown fox jumps over the lazy dog"
}'Moderations
Check content compliance.
curl https://api.aize.dev/v1/moderations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "text-moderation-latest",
"input": "Sample text to check"
}'