Introduction
The Zubnet API is fully compatible with the OpenAI API specification. If you're already using OpenAI, you can switch to Zubnet by changing your base URL and API key - your existing code will work without modification.
Base URL
https://api.zubnet.com/v1
Quick Start
# Using curl curl https://api.zubnet.com/v1/chat/completions \ -H "Authorization: Bearer $ZUBNET_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "claude-sonnet-4-20250514", "messages": [{"role": "user", "content": "Hello!"}] }'
# Using Python with OpenAI SDK from openai import OpenAI client = OpenAI( api_key="your-zubnet-api-key", base_url="https://api.zubnet.com/v1" ) response = client.chat.completions.create( model="claude-sonnet-4-20250514", messages=[{"role": "user", "content": "Hello!"}] ) print(response.choices[0].message.content)
Authentication
All API requests require authentication via Bearer token in the Authorization header.
Authorization: Bearer YOUR_API_KEY
You can generate API keys from your account settings. Keep your keys secure - they grant full access to your account.
Using Your Own Provider Keys (BYOK)
You can also use your own API keys from providers like OpenAI or Anthropic. Add them in your account settings and they'll be used automatically for requests to those providers.
Models
List all available models.
curl https://api.zubnet.com/v1/models \
-H "Authorization: Bearer $ZUBNET_API_KEY"
{
"object": "list",
"data": [
{
"id": "claude-sonnet-4-20250514",
"object": "model",
"created": 1699900000,
"owned_by": "anthropic"
},
{
"id": "gpt-4o",
"object": "model",
"created": 1699900000,
"owned_by": "openai"
},
...
]
}
Chat Completions
Create a chat completion. This is the primary endpoint for text generation.
Request Body
| Parameter | Type | Description |
|---|---|---|
modelrequired |
string | Model ID to use (e.g., "claude-sonnet-4-20250514", "gpt-4o") |
messagesrequired |
array | Array of message objects with role and content |
temperatureoptional |
number | Sampling temperature (0-2). Default: 1 |
max_tokensoptional |
integer | Maximum tokens to generate |
streamoptional |
boolean | Stream responses via SSE. Default: false |
top_poptional |
number | Nucleus sampling parameter. Default: 1 |
stopoptional |
string/array | Stop sequences |
Example Request
curl https://api.zubnet.com/v1/chat/completions \ -H "Authorization: Bearer $ZUBNET_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "claude-sonnet-4-20250514", "messages": [ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What is the capital of France?"} ], "temperature": 0.7, "max_tokens": 150 }'
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1699900000,
"model": "claude-sonnet-4-20250514",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "The capital of France is Paris."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 25,
"completion_tokens": 8,
"total_tokens": 33
}
}
Image Generation
Generate images from text prompts.
Request Body
| Parameter | Type | Description |
|---|---|---|
modelrequired |
string | Image model to use (e.g., "flux-pro", "dall-e-3") |
promptrequired |
string | Text description of the image to generate |
noptional |
integer | Number of images to generate. Default: 1 |
sizeoptional |
string | Image size (e.g., "1024x1024", "1792x1024") |
response_formatoptional |
string | "url" or "b64_json". Default: "url" |
Example Request
curl https://api.zubnet.com/v1/images/generations \ -H "Authorization: Bearer $ZUBNET_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "flux-pro", "prompt": "A serene mountain lake at sunset, photorealistic", "n": 1, "size": "1024x1024" }'
{
"created": 1699900000,
"data": [
{
"url": "https://cdn.zubnet.com/images/abc123.png",
"revised_prompt": "A serene mountain lake..."
}
]
}
Audio
Text-to-Speech
Convert text to speech audio.
| Parameter | Type | Description |
|---|---|---|
modelrequired |
string | TTS model to use (e.g., "tts-1", "tts-1-hd", "elevenlabs") |
inputrequired |
string | Text to convert to speech |
voicerequired |
string | Voice to use (e.g., "alloy", "echo", "nova") |
response_formatoptional |
string | Audio format: mp3, opus, aac, flac. Default: mp3 |
Transcription
Transcribe audio to text.
| Parameter | Type | Description |
|---|---|---|
modelrequired |
string | Transcription model (e.g., "whisper-1") |
filerequired |
file | Audio file to transcribe |
languageoptional |
string | Language code (e.g., "en", "fr") |
Embeddings
Create text embeddings for semantic search and similarity.
| Parameter | Type | Description |
|---|---|---|
modelrequired |
string | Embedding model (e.g., "text-embedding-3-small") |
inputrequired |
string/array | Text to embed (string or array of strings) |
Example Request
curl https://api.zubnet.com/v1/embeddings \ -H "Authorization: Bearer $ZUBNET_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "text-embedding-3-small", "input": "The quick brown fox jumps over the lazy dog" }'
Errors
The API uses standard HTTP status codes and returns detailed error messages.
| Code | Description |
|---|---|
400 |
Bad Request - Invalid parameters |
401 |
Unauthorized - Invalid or missing API key |
403 |
Forbidden - Insufficient permissions |
404 |
Not Found - Model or resource not found |
429 |
Too Many Requests - Rate limit exceeded |
500 |
Internal Server Error |
503 |
Service Unavailable - Temporary overload |
{
"error": {
"message": "Invalid API key provided",
"type": "authentication_error",
"code": "invalid_api_key"
}
}
Rate Limits
Rate limits vary by plan. Headers are included in every response:
| Header | Description |
|---|---|
X-RateLimit-Limit |
Requests allowed per minute |
X-RateLimit-Remaining |
Requests remaining in current window |
X-RateLimit-Reset |
Unix timestamp when limit resets |
If you hit a rate limit, wait until the reset time or contact us to increase your limits.
We're Here for You
Questions about the API? Check our FAQ or reach out directly.