OpenAI-Compatible
AI API Documentation

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.

Image Generation
Music & Voice
Video Creation
LLM Chat
Quick Start
curl -X POST "https://api.univence.com/v1/images/generations" \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/" \
-d '{"prompt": "a cat on the moon"}'

Overview

Everything you need to know about the OpenAI-Compatible AI API

Base URL

https://api.univence.com

Authentication

All endpoints require authentication via:

  • API Key: Include X-API-Key: your-api-key in headers
  • Bearer Token: Include Authorization: Bearer your-jwt-token in headers

Content Type

All 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.

API Endpoints

Complete documentation for all AI API endpoints

POST
/v1/images/generations

1. Text-to-Image Generation

Generate images from text prompts. Supports multiple sizes, styles, and output formats.

Request

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"
  }'

Parameters

ParameterTypeRequiredDescriptionDefault
promptstringYesText description of the image to generate (max 4000 characters)
nintegerNoNumber of images to generate (1-10)1
sizestringNoImage size: 256x256, 512x512, 1024x1024, 1024x1792, 1792x10241024x1024
response_formatstringNourl or b64_url
qualitystringNostandard or hdstandard
stylestringNovivid or naturalvivid

Response

{
  "created": 1700000000,
  "data": [
    {
      "url": "https://cdn.univence.com/images/abc123.png"
    }
  ]
}
POST
/v1/images/edits

2. Image Editing

Edit an existing image using a text prompt. Upload an original image and optionally a mask to specify which areas to edit.

Request

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"

Parameters

ParameterTypeRequiredDescription
imagefileYesThe original image to edit (PNG, max 4MB)
promptstringYesDescription of the edit to apply (max 1000 characters)
maskfileNoMask image — fully transparent areas indicate where to edit
nintegerNoNumber of edited images to generate (1-10)
sizestringNoOutput size: 256x256, 512x512, 1024x1024

Response

{
  "created": 1700000000,
  "data": [
    {
      "url": "https://cdn.univence.com/images/edited123.png"
    }
  ]
}
POST
/v1/images/variations

3. Image Variations

Generate variations of an existing image. The API creates alternative versions based on the uploaded image.

Request

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"

Parameters

ParameterTypeRequiredDescription
imagefileYesThe source image (PNG, max 4MB, square recommended)
nintegerNoNumber of variations to generate (1-10)
sizestringNoOutput size: 256x256, 512x512, 1024x1024

Response

{
  "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" }
  ]
}
POST
/v1/images/upscale

4. Image Upscaling

Increase the resolution of an image using AI super-resolution. Supports up to 4x upscaling while preserving and enhancing detail.

Request

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"

Parameters

ParameterTypeRequiredDescriptionDefault
imagefileYesThe image to upscale (PNG/JPG, max 10MB)
scaleintegerNoUpscale factor: 2, 3, or 42
face_enhancebooleanNoApply face enhancement (GFPGAN) for portraitsfalse

Response

{
  "success": true,
  "data": {
    "url": "https://cdn.univence.com/images/upscaled123.png",
    "original_size": "512x512",
    "upscaled_size": "1024x1024"
  }
}
POST
/v1/images/remove-background

5. Background Removal

Remove the background from an image automatically. Returns a transparent PNG with only the foreground subject.

Request

curl -X POST "https://api.univence.com/v1/images/remove-background" \
  -H "X-API-Key: your-api-key" \
  -F "image=@photo.jpg"

Parameters

ParameterTypeRequiredDescription
imagefileYesThe image to process (PNG/JPG, max 10MB)

Response

{
  "success": true,
  "data": {
    "url": "https://cdn.univence.com/images/nobg123.png"
  }
}
POST
/v1/images/segmentation

6. Object Segmentation (SAM)

Segment objects in an image using Segment Anything Model (SAM). Supports point-based, box-based, and automatic segmentation modes.

Request

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}]
  }'

Parameters

ParameterTypeRequiredDescriptionDefault
image_urlstringYesURL of the image to segment
modestringNoauto, point, or boxauto
pointsarrayNoArray of {x, y, label} points for point-based mode[]
boxobjectNoBounding box {x1, y1, x2, y2} for box modenull

Response

{
  "success": true,
  "data": {
    "masks": [
      {
        "segmentation_url": "https://cdn.univence.com/masks/mask1.png",
        "area": 45000,
        "bbox": [100, 80, 300, 280],
        "score": 0.95
      }
    ]
  }
}
POST
/v1/images/img2video

7. Image to Video Generation

Transform a static image into a short video clip using AI animation. Provide an image and optional motion parameters.

Request

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
  }'

Parameters

ParameterTypeRequiredDescriptionDefault
image_urlstringYesURL of the source image
durationintegerNoVideo duration in seconds (2-8)4
fpsintegerNoFrames per second (8, 15, 24, or 30)24
motion_strengthnumberNoMotion intensity from 0.0 to 1.00.5

Response

{
  "success": true,
  "data": {
    "url": "https://cdn.univence.com/videos/video123.mp4",
    "duration": 4,
    "fps": 24
  }
}
POST
/v1/chat/completions

8. LLM Chat Completions

Chat with large language models. Fully OpenAI-compatible — supports streaming, function calling, system prompts, and multi-turn conversations.

Request

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
  }'

Parameters

ParameterTypeRequiredDescriptionDefault
modelstringYesModel ID (see Supported Models)
messagesarrayYesArray of message objects with role and content
temperaturenumberNoSampling temperature (0.0-2.0)1.0
max_tokensintegerNoMaximum tokens to generatevaries
streambooleanNoStream response tokens via SSEfalse
toolsarrayNoFunction/tool definitions for function callingnull

Response

{
  "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
  }
}
POST
/v1/audio/speech

9. Text-to-Speech (TTS)

Convert text to natural-sounding speech. Supports multiple voices, languages, and audio formats.

Request

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

Parameters

ParameterTypeRequiredDescriptionDefault
inputstringYesText to convert to speech (max 4096 characters)
voicestringNoVoice: alloy, echo, fable, onyx, nova, shimmeralloy
response_formatstringNoAudio format: mp3, opus, aac, flac, wavmp3
speednumberNoSpeed multiplier (0.25-4.0)1.0

Response

Returns the audio file directly as a binary stream with the appropriate Content-Type header.

POST
/v1/audio/transcriptions

10. Speech-to-Text (STT)

Transcribe audio files to text. Supports multiple audio formats and automatic language detection.

Request

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"

Parameters

ParameterTypeRequiredDescriptionDefault
filefileYesAudio file (mp3, mp4, m4a, wav, webm; max 25MB)
modelstringYesModel ID (e.g., whisper-1)
languagestringNoISO-639-1 language code (e.g., en, ko, ja)auto
response_formatstringNo, text, srt, vtt

Response

{
  "text": "Hello, how are you today?"
}
POST
/v1/audio/clone

11. Voice Cloning

Clone a voice from an audio sample. Upload a reference audio clip, then generate speech in that voice from any text.

Request

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"
  }'

Parameters

ParameterTypeRequiredDescription
reference_audio_urlstringYesURL of the reference voice sample (5-30 seconds recommended)
textstringYesText to synthesize in the cloned voice
languagestringNoISO-639-1 language code for output speech

Response

{
  "success": true,
  "data": {
    "url": "https://cdn.univence.com/audio/cloned123.wav"
  }
}
POST
/v1/music/generate

12. Music Generation

Generate music tracks from text descriptions. Specify genre, mood, instruments, and duration.

Request

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"
  }'

Parameters

ParameterTypeRequiredDescriptionDefault
promptstringYesDescription of the music (genre, mood, instruments)
durationintegerNoDuration in seconds (5-180)30
tempointegerNoBPM (60-200)120
formatstringNoAudio format: mp3 or wavmp3

Response

{
  "success": true,
  "data": {
    "url": "https://cdn.univence.com/music/track123.mp3",
    "duration": 30
  }
}
GET
/v1/models

13. List Available Models

List all available AI models, including image, language, and audio models.

Request

curl -X GET "https://api.univence.com/v1/models" \
  -H "X-API-Key: your-api-key"

Response

{
  "object": "list",
  "data": [
    {
      "id": "dall-e-3",
      "object": "model",
      "created": 1700000000,
      "owned_by": "univence"
    },
    {
      "id": "gpt-4o",
      "object": "model",
      "created": 1700000000,
      "owned_by": "univence"
    }
  ]
}

Supported Models

AI models available through the API

dall-e-3

Image
Max Size1792x1024
QualityHD
StylesVivid, Natural
FormatURL, Base64

Latest DALL-E model for high-quality text-to-image generation with advanced prompt understanding and vivid detail.

gpt-4o

LLM
Context128K tokens
StreamingYes
VisionYes
FunctionsYes

Multimodal LLM with vision, function calling, and streaming support. Excellent for chat, reasoning, and code generation.

whisper-1

Audio
Languages99+
Max File25 MB
Formatsmp3, wav, m4a
Output, srt, vtt

State-of-the-art speech recognition model. Supports automatic language detection and timestamp-level transcription.

tts-1

TTS
Voices6 voices
Speed0.25x-4x
Formatmp3, opus, wav
Max Input4096 chars

High-quality text-to-speech model with natural-sounding voices in multiple languages.

sam-vit-huge

Vision
ModesAuto, Point, Box
OutputMask + Metadata
PrecisionHigh
SpeedFast

Segment Anything Model for zero-shot object segmentation. Supports interactive point and box prompts.

real-esrgan

Upscale
Max Scale4x
Face EnhanceYes (GFPGAN)
Max File10 MB
FormatsPNG, JPG

AI super-resolution model for upscaling images up to 4x with optional face enhancement for portraits.

Usage Examples

End-to-end examples for common use cases

Generate an Image

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.

Chat with LLM (Python)

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.

Remove Background

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.

Clone a Voice

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.

Generate Music

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.

Upscale an Image

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.

Image to Video

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.

Text-to-Speech

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.

Error Handling

Common error responses and how to handle them

Status CodeError TypeDescriptionSolution
400Bad RequestInvalid parameters or malformed requestCheck request body and parameter types
401UnauthorizedMissing or invalid API keyVerify X-API-Key header is correct
403ForbiddenInsufficient credits or permissionsCheck account credits and API access
404Not FoundEndpoint or model not foundVerify endpoint URL and model ID
429Rate LimitedToo many requestsImplement exponential backoff and retry
500Server ErrorInternal processing errorRetry with backoff; contact support if persistent
503Service UnavailableModel temporarily overloadedWait and retry; consider fallback model
// Example error response
{
  "error": {
    "message": "Invalid API key provided",
    "type": "authentication_error",
    "code": "invalid_api_key"
  }
}

Credits & Pricing

Credit costs per operation

OperationCreditsNotes
Image Generation (standard)1 creditPer image, standard quality
Image Generation (HD)2 creditsPer image, HD quality
Image Edit / Variation1 creditPer output image
Image Upscale1 creditPer image, any scale factor
Background Removal1 creditPer image
Object Segmentation1 creditPer image
Image to Video5 creditsPer video clip
Chat Completion1 creditPer 1K tokens
Text-to-Speech1 creditPer 1K characters
Speech-to-Text1 creditPer minute of audio
Voice Cloning3 creditsPer synthesis
Music Generation3 creditsPer 30 seconds

Credit Balance: Check your credit balance at univence.com/account.

Low Credits: Requests will return a 403 Forbidden when credits are exhausted.

Rate Limiting

Request limits and best practices

TierRequests/minRequests/day
Free10100
Starter301,000
Pro6010,000
Enterprise200Unlimited

Rate Limit Headers: Every response includes X-RateLimit-Limit, X-RateLimit-Remaining, and X-RateLimit-Reset headers.

Best Practices

Tips for getting the most out of the API

Prompt Engineering

  • Be specific and descriptive in image prompts
  • Include style, mood, lighting, and composition details
  • Use style: vivid for more dramatic results
  • Test different temperature values for LLM chat

Error Handling

  • Always implement retry logic with exponential backoff
  • Handle 429 rate limit errors gracefully
  • Cache responses when possible to reduce API calls
  • Set reasonable timeouts for long-running operations

Performance

  • Use streaming (stream: true) for chat completions
  • Batch multiple image generations with the n parameter
  • Use response_format: url instead of base64 for large images
  • Compress images before uploading for edits/upscaling

Credit Management

  • Monitor credit usage via the account dashboard
  • Cache frequently used responses to save credits
  • Use standard quality when HD is not needed
  • Set up low-credit alerts to avoid service interruption

Ready to Build?

Start generating with the Univence AI API today