Generate images, edit photos, segment objects, upscale resolution, remove backgrounds, generate music, create videos, chat with LLMs, and clone voices — all through a single unified API.
Everything you need to know about the OpenAI-Compatible AI API
https://api.univence.com
All endpoints require authentication via:
X-API-Key: your-api-key in headersAuthorization: Bearer your-jwt-token in headersAll POST endpoints accept application/ for JSON payloads and multipart/form-data for file uploads.
Note: This API is OpenAI-compatible. You can use existing OpenAI SDKs and client libraries by simply changing the base_url to https://api.univence.com/v1.
Complete documentation for all AI API endpoints
Generate images from text prompts. Supports multiple sizes, styles, and output formats.
curl -X POST "https://api.univence.com/v1/images/generations" \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/" \
-d '{
"prompt": "a futuristic city at sunset, cyberpunk style",
"n": 1,
"size": "1024x1024"
}'
| Parameter | Type | Required | Description | Default |
|---|---|---|---|---|
prompt | string | Yes | Text description of the image to generate (max 4000 characters) | — |
n | integer | No | Number of images to generate (1-10) | 1 |
size | string | No | Image size: 256x256, 512x512, 1024x1024, 1024x1792, 1792x1024 | 1024x1024 |
response_format | string | No | url or b64_ | url |
quality | string | No | standard or hd | standard |
style | string | No | vivid or natural | vivid |
{
"created": 1700000000,
"data": [
{
"url": "https://cdn.univence.com/images/abc123.png"
}
]
}
Edit an existing image using a text prompt. Upload an original image and optionally a mask to specify which areas to edit.
curl -X POST "https://api.univence.com/v1/images/edits" \
-H "X-API-Key: your-api-key" \
-F "image=@original.png" \
-F "mask=@mask.png" \
-F "prompt=add sunglasses to the person" \
-F "size=1024x1024"
| Parameter | Type | Required | Description |
|---|---|---|---|
image | file | Yes | The original image to edit (PNG, max 4MB) |
prompt | string | Yes | Description of the edit to apply (max 1000 characters) |
mask | file | No | Mask image — fully transparent areas indicate where to edit |
n | integer | No | Number of edited images to generate (1-10) |
size | string | No | Output size: 256x256, 512x512, 1024x1024 |
{
"created": 1700000000,
"data": [
{
"url": "https://cdn.univence.com/images/edited123.png"
}
]
}
Generate variations of an existing image. The API creates alternative versions based on the uploaded image.
curl -X POST "https://api.univence.com/v1/images/variations" \
-H "X-API-Key: your-api-key" \
-F "image=@original.png" \
-F "n=3" \
-F "size=1024x1024"
| Parameter | Type | Required | Description |
|---|---|---|---|
image | file | Yes | The source image (PNG, max 4MB, square recommended) |
n | integer | No | Number of variations to generate (1-10) |
size | string | No | Output size: 256x256, 512x512, 1024x1024 |
{
"created": 1700000000,
"data": [
{ "url": "https://cdn.univence.com/images/var1.png" },
{ "url": "https://cdn.univence.com/images/var2.png" },
{ "url": "https://cdn.univence.com/images/var3.png" }
]
}
Increase the resolution of an image using AI super-resolution. Supports up to 4x upscaling while preserving and enhancing detail.
curl -X POST "https://api.univence.com/v1/images/upscale" \
-H "X-API-Key: your-api-key" \
-F "image=@low-res.png" \
-F "scale=2"
| Parameter | Type | Required | Description | Default |
|---|---|---|---|---|
image | file | Yes | The image to upscale (PNG/JPG, max 10MB) | — |
scale | integer | No | Upscale factor: 2, 3, or 4 | 2 |
face_enhance | boolean | No | Apply face enhancement (GFPGAN) for portraits | false |
{
"success": true,
"data": {
"url": "https://cdn.univence.com/images/upscaled123.png",
"original_size": "512x512",
"upscaled_size": "1024x1024"
}
}
Remove the background from an image automatically. Returns a transparent PNG with only the foreground subject.
curl -X POST "https://api.univence.com/v1/images/remove-background" \
-H "X-API-Key: your-api-key" \
-F "image=@photo.jpg"
| Parameter | Type | Required | Description |
|---|---|---|---|
image | file | Yes | The image to process (PNG/JPG, max 10MB) |
{
"success": true,
"data": {
"url": "https://cdn.univence.com/images/nobg123.png"
}
}
Segment objects in an image using Segment Anything Model (SAM). Supports point-based, box-based, and automatic segmentation modes.
curl -X POST "https://api.univence.com/v1/images/segmentation" \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/" \
-d '{
"image_url": "https://example.com/photo.jpg",
"mode": "auto",
"points": [{"x": 320, "y": 240, "label": 1}]
}'
| Parameter | Type | Required | Description | Default |
|---|---|---|---|---|
image_url | string | Yes | URL of the image to segment | — |
mode | string | No | auto, point, or box | auto |
points | array | No | Array of {x, y, label} points for point-based mode | [] |
box | object | No | Bounding box {x1, y1, x2, y2} for box mode | null |
{
"success": true,
"data": {
"masks": [
{
"segmentation_url": "https://cdn.univence.com/masks/mask1.png",
"area": 45000,
"bbox": [100, 80, 300, 280],
"score": 0.95
}
]
}
}
Transform a static image into a short video clip using AI animation. Provide an image and optional motion parameters.
curl -X POST "https://api.univence.com/v1/images/img2video" \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/" \
-d '{
"image_url": "https://example.com/landscape.jpg",
"duration": 4,
"fps": 24,
"motion_strength": 0.5
}'
| Parameter | Type | Required | Description | Default |
|---|---|---|---|---|
image_url | string | Yes | URL of the source image | — |
duration | integer | No | Video duration in seconds (2-8) | 4 |
fps | integer | No | Frames per second (8, 15, 24, or 30) | 24 |
motion_strength | number | No | Motion intensity from 0.0 to 1.0 | 0.5 |
{
"success": true,
"data": {
"url": "https://cdn.univence.com/videos/video123.mp4",
"duration": 4,
"fps": 24
}
}
Chat with large language models. Fully OpenAI-compatible — supports streaming, function calling, system prompts, and multi-turn conversations.
curl -X POST "https://api.univence.com/v1/chat/completions" \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/" \
-d '{
"model": "gpt-4o",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is the capital of France?"}
],
"temperature": 0.7,
"max_tokens": 1000,
"stream": false
}'
| Parameter | Type | Required | Description | Default |
|---|---|---|---|---|
model | string | Yes | Model ID (see Supported Models) | — |
messages | array | Yes | Array of message objects with role and content | — |
temperature | number | No | Sampling temperature (0.0-2.0) | 1.0 |
max_tokens | integer | No | Maximum tokens to generate | varies |
stream | boolean | No | Stream response tokens via SSE | false |
tools | array | No | Function/tool definitions for function calling | null |
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1700000000,
"model": "gpt-4o",
"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
}
}
Convert text to natural-sounding speech. Supports multiple voices, languages, and audio formats.
curl -X POST "https://api.univence.com/v1/audio/speech" \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/" \
-d '{
"model": "tts-1",
"input": "Hello, how are you today?",
"voice": "alloy",
"response_format": "mp3",
"speed": 1.0
}' --output speech.mp3
| Parameter | Type | Required | Description | Default |
|---|---|---|---|---|
input | string | Yes | Text to convert to speech (max 4096 characters) | — |
voice | string | No | Voice: alloy, echo, fable, onyx, nova, shimmer | alloy |
response_format | string | No | Audio format: mp3, opus, aac, flac, wav | mp3 |
speed | number | No | Speed multiplier (0.25-4.0) | 1.0 |
Returns the audio file directly as a binary stream with the appropriate Content-Type header.
Transcribe audio files to text. Supports multiple audio formats and automatic language detection.
curl -X POST "https://api.univence.com/v1/audio/transcriptions" \
-H "X-API-Key: your-api-key" \
-F "file=@audio.mp3" \
-F "model=whisper-1" \
-F "language=en"
| Parameter | Type | Required | Description | Default |
|---|---|---|---|---|
file | file | Yes | Audio file (mp3, mp4, m4a, wav, webm; max 25MB) | — |
model | string | Yes | Model ID (e.g., whisper-1) | — |
language | string | No | ISO-639-1 language code (e.g., en, ko, ja) | auto |
response_format | string | No | , text, srt, vtt |
{
"text": "Hello, how are you today?"
}
Clone a voice from an audio sample. Upload a reference audio clip, then generate speech in that voice from any text.
curl -X POST "https://api.univence.com/v1/audio/clone" \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/" \
-d '{
"reference_audio_url": "https://example.com/voice-sample.wav",
"text": "This is the text I want spoken in the cloned voice.",
"language": "en"
}'
| Parameter | Type | Required | Description |
|---|---|---|---|
reference_audio_url | string | Yes | URL of the reference voice sample (5-30 seconds recommended) |
text | string | Yes | Text to synthesize in the cloned voice |
language | string | No | ISO-639-1 language code for output speech |
{
"success": true,
"data": {
"url": "https://cdn.univence.com/audio/cloned123.wav"
}
}
Generate music tracks from text descriptions. Specify genre, mood, instruments, and duration.
curl -X POST "https://api.univence.com/v1/music/generate" \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/" \
-d '{
"prompt": "upbeat electronic dance music with heavy bass",
"duration": 30,
"tempo": 128,
"format": "mp3"
}'
| Parameter | Type | Required | Description | Default |
|---|---|---|---|---|
prompt | string | Yes | Description of the music (genre, mood, instruments) | — |
duration | integer | No | Duration in seconds (5-180) | 30 |
tempo | integer | No | BPM (60-200) | 120 |
format | string | No | Audio format: mp3 or wav | mp3 |
{
"success": true,
"data": {
"url": "https://cdn.univence.com/music/track123.mp3",
"duration": 30
}
}
List all available AI models, including image, language, and audio models.
curl -X GET "https://api.univence.com/v1/models" \
-H "X-API-Key: your-api-key"
{
"object": "list",
"data": [
{
"id": "dall-e-3",
"object": "model",
"created": 1700000000,
"owned_by": "univence"
},
{
"id": "gpt-4o",
"object": "model",
"created": 1700000000,
"owned_by": "univence"
}
]
}
AI models available through the API
Latest DALL-E model for high-quality text-to-image generation with advanced prompt understanding and vivid detail.
Multimodal LLM with vision, function calling, and streaming support. Excellent for chat, reasoning, and code generation.
State-of-the-art speech recognition model. Supports automatic language detection and timestamp-level transcription.
High-quality text-to-speech model with natural-sounding voices in multiple languages.
Segment Anything Model for zero-shot object segmentation. Supports interactive point and box prompts.
AI super-resolution model for upscaling images up to 4x with optional face enhancement for portraits.
End-to-end examples for common use cases
curl -X POST "https://api.univence.com/v1/images/generations" \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/" \
-d '{"prompt": "astronaut riding a horse on Mars"}'
Expected: Returns a generated image URL.
from openai import OpenAI
client = OpenAI(
api_key="your-api-key",
base_url="https://api.univence.com/v1"
)
response = client.chat.completions.create(
model="gpt-4o",
messages=[
{"role": "user", "content": "Hello!"}
]
)
print(response.choices[0].message.content)
Expected: Returns a chat completion response.
curl -X POST "https://api.univence.com/v1/images/remove-background" \
-H "X-API-Key: your-api-key" \
-F "image=@product-photo.jpg"
Expected: Returns a transparent PNG with the background removed.
curl -X POST "https://api.univence.com/v1/audio/clone" \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/" \
-d '{
"reference_audio_url": "https://example.com/voice.wav",
"text": "Hello world, this is a cloned voice."
}'
Expected: Returns an audio file URL in the cloned voice.
curl -X POST "https://api.univence.com/v1/music/generate" \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/" \
-d '{
"prompt": "lo-fi hip hop beat, chill, rainy night vibes",
"duration": 60
}'
Expected: Returns a music track URL.
curl -X POST "https://api.univence.com/v1/images/upscale" \
-H "X-API-Key: your-api-key" \
-F "image=@low-res.png" \
-F "scale=4"
Expected: Returns a 4x upscaled image URL.
curl -X POST "https://api.univence.com/v1/images/img2video" \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/" \
-d '{
"image_url": "https://example.com/scene.jpg",
"duration": 4
}'
Expected: Returns a short animated video URL.
curl -X POST "https://api.univence.com/v1/audio/speech" \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/" \
-d '{
"input": "Welcome to Univence AI.",
"voice": "nova"
}' --output welcome.mp3
Expected: Downloads an MP3 audio file.
Common error responses and how to handle them
| Status Code | Error Type | Description | Solution |
|---|---|---|---|
400 | Bad Request | Invalid parameters or malformed request | Check request body and parameter types |
401 | Unauthorized | Missing or invalid API key | Verify X-API-Key header is correct |
403 | Forbidden | Insufficient credits or permissions | Check account credits and API access |
404 | Not Found | Endpoint or model not found | Verify endpoint URL and model ID |
429 | Rate Limited | Too many requests | Implement exponential backoff and retry |
500 | Server Error | Internal processing error | Retry with backoff; contact support if persistent |
503 | Service Unavailable | Model temporarily overloaded | Wait and retry; consider fallback model |
// Example error response
{
"error": {
"message": "Invalid API key provided",
"type": "authentication_error",
"code": "invalid_api_key"
}
}
Credit costs per operation
| Operation | Credits | Notes |
|---|---|---|
| Image Generation (standard) | 1 credit | Per image, standard quality |
| Image Generation (HD) | 2 credits | Per image, HD quality |
| Image Edit / Variation | 1 credit | Per output image |
| Image Upscale | 1 credit | Per image, any scale factor |
| Background Removal | 1 credit | Per image |
| Object Segmentation | 1 credit | Per image |
| Image to Video | 5 credits | Per video clip |
| Chat Completion | 1 credit | Per 1K tokens |
| Text-to-Speech | 1 credit | Per 1K characters |
| Speech-to-Text | 1 credit | Per minute of audio |
| Voice Cloning | 3 credits | Per synthesis |
| Music Generation | 3 credits | Per 30 seconds |
Credit Balance: Check your credit balance at univence.com/account.
Low Credits: Requests will return a 403 Forbidden when credits are exhausted.
Request limits and best practices
| Tier | Requests/min | Requests/day |
|---|---|---|
| Free | 10 | 100 |
| Starter | 30 | 1,000 |
| Pro | 60 | 10,000 |
| Enterprise | 200 | Unlimited |
Rate Limit Headers: Every response includes X-RateLimit-Limit, X-RateLimit-Remaining, and X-RateLimit-Reset headers.
Tips for getting the most out of the API
style: vivid for more dramatic resultstemperature values for LLM chat429 rate limit errors gracefullystream: true) for chat completionsn parameterresponse_format: url instead of base64 for large images