API REFERENCE

Introduction
Authentication
Errors
LLM — Text
Image Generation
Text to Speech
Transcription

Introduction

Apiarium provides a unified REST API to access multiple AI models under a single API key. No need to manage separate accounts for OpenAI, Anthropic or other providers.

Base URL:

https://apiarium-api-production.up.railway.app

Authentication

All requests must include your API key in the Authorization header using the Bearer scheme.

Authorization: Bearer sk_apiarium_live_...

You can find your API key in your dashboard. Keep it secret — never expose it in client-side code.

Errors

Apiarium uses standard HTTP status codes. All errors return a JSON object with an error field.

200Success
400Bad request — missing or invalid parameters
401Unauthorized — invalid or missing API key
402Insufficient credits
429Rate limit exceeded
500Internal server error

LLM — Text Generation

POST/llm

Generate text using GPT-4o-mini. Send a list of messages in OpenAI chat format and receive a completion.

Parameters

PARAMTYPEREQDESCRIPTION
messagesarrayYesArray of message objects with role (user/assistant/system) and content
modelstringNoModel to use. Default: gpt-4o-mini
max_tokensnumberNoMaximum tokens to generate. Default: 1000

Example

curl
javascript
python
curl -X POST https://apiarium-api-production.up.railway.app/llm \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "messages": [
      { "role": "user", "content": "Write a tagline for a coffee brand" }
    ]
  }'

Response

{
  "content": "Brew the moment.",
  "credits_used": 2,
  "credits_remaining": 9998
}

Image Generation

POST/image

Generate images using DALL-E 3. Returns a URL to the generated image. Each image costs 100 credits.

Parameters

PARAMTYPEREQDESCRIPTION
promptstringYesText description of the image to generate
sizestringNo1024x1024 (default), 1792x1024, or 1024x1792

Example

curl
javascript
python
curl -X POST https://apiarium-api-production.up.railway.app/image \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A futuristic city at sunset, digital art",
    "size": "1024x1024"
  }'

Response

{
  "url": "https://oaidalleapiprodscus.blob.core.windows.net/...",
  "credits_used": 100,
  "credits_remaining": 9900
}

Text to Speech

POST/tts

Convert text to natural-sounding audio. Returns an MP3 audio stream. Costs 5 credits per 1,000 characters.

Parameters

PARAMTYPEREQDESCRIPTION
textstringYesThe text to convert to speech
voicestringNoalloy (default), echo, fable, onyx, nova, shimmer

Example

curl
javascript
python
curl -X POST https://apiarium-api-production.up.railway.app/tts \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text": "Hello from Apiarium", "voice": "nova"}' \
  --output audio.mp3

Response

Returns a binary MP3 audio stream with Content-Type: audio/mpeg. Headers include:

Content-Type: audio/mpeg
X-Credits-Used: 5
X-Credits-Remaining: 9995

Transcription

POST/transcribe

Transcribe audio to text using Whisper. Send an audio file as multipart/form-data. Costs 10 credits per minute of audio.

Parameters

PARAMTYPEREQDESCRIPTION
filefileYesAudio file (mp3, mp4, wav, m4a, webm). Max 25MB.

Example

curl
javascript
python
curl -X POST https://apiarium-api-production.up.railway.app/transcribe \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "file=@audio.mp3"

Response

{
  "text": "Hello, this is a transcription of the audio file.",
  "credits_used": 10,
  "credits_remaining": 9990
}