APIARIUM
Home
Sign in
Get started

API REFERENCE

Introduction
Authentication
Credits
Credit Packs
Multi-currency
Rate Limits
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, Google or other providers.

Coming from OpenRouter or LiteLLM? See how OpenRouter migration works · or LiteLLM →

Base URL:

https://api.apiarium.dev

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.

Credits

Credits are Apiarium's unit of consumption. Each request deducts credits based on the model used and the size of the task. Your balance is always visible in your dashboard.

Your account has two credit balances: plan credits (included with your subscription, reset monthly for paid plans) and extra credits (purchased separately via credit packs — see below). Plan credits are used first; extra credits are used automatically once your plan credits run out.

OPERATIONCREDITS
Text — gpt-4o-mini (per request)1–5
Text — claude-haiku (per request)8–38
Text — gemini (per request)13–63
Text — gpt-4o (per request)17–83
Text — claude-sonnet (per request)23–113
Image — gpt-image-1, low quality50
Image — gpt-image-1, medium quality (default)100
Image — gpt-image-1, high quality200
Image — gemini-flash-image (Starter / Pro)90
Image — gpt-image-2 (Pro)200
Image — gemini-pro-image (Pro)220
Text to Speech — tts-1 (per 1,000 characters)18
Text to Speech — gemini-tts (per 1,000 characters)44
Transcription (per minute of audio)10

Text generation cost depends on the number of tokens processed and the model used. Credits are calculated as: model_multiplier × (input_tokens × 0.75 + output_tokens × 4.50) / 1000, with a minimum of 1 credit per request. The multiplier reflects each model's real cost (gpt-4o-mini = 1x, claude-haiku = 7.5x, gemini = 12.5x, gpt-4o = 16.5x, claude-sonnet = 22.5x) — this is why models cost proportionally more, not just a flat token count.

Credit Packs

Need more credits without waiting for your monthly reset? You can buy credit packs at any time — no subscription required. Purchased credits never expire before 12 months and are used automatically once your plan credits run out.

There are two pricing tiers, applied automatically based on your account:

Pay-as-you-goFor Free plan accounts — no active subscription
Top-upFor Starter/Pro subscribers — lower rate as a subscriber benefit

List active packs

GET/stripe/credits/packs

Returns your active (non-expired, non-refunded) credit packs, along with the total extra balance. Requires a Supabase session token, not an API key — this endpoint is used by the dashboard, not for programmatic API usage.

{
  "packs": [
    {
      "id": "74da67c7-...",
      "source": "payasyougo",
      "credits_original": 1714,
      "credits_remaining": 1618,
      "expires_at": "2027-07-02T13:14:13.969+00:00",
      "created_at": "2026-07-02T13:14:14.382553+00:00",
      "refunded": false,
      "expired": false
    }
  ],
  "total_extra": 1618
}

Multi-currency

Apiarium supports billing in 10 currencies: EUR, USD, GBP, CAD, INR, AUD, BRL, MXN, JPY, and SGD. Currency is detected automatically based on your location when you visit the pricing page.

Subscription prices are fixed per currency (not a live conversion) — each plan has a dedicated price for each supported currency. Pay-as-you-go and top-up purchases calculate the exact credit amount at checkout time based on the amount and currency you choose.

All amounts sent to the API (subscription checkout, credit pack purchases) must include a currency field matching one of the supported codes below, in lowercase:

eur
usd
gbp
cad
inr
aud
brl
mxn
jpy
sgd

Rate Limits

Each endpoint has its own rate limit. /llm, /tts, and /transcribe are applied per IP address. /image is different: it's a shared capacity pool across every Apiarium user, because it's constrained by our upstream AI providers' own account-wide limits rather than by any single user's traffic. If you exceed a limit, requests return a 429 status until capacity frees up.

/llm30 requests / minute (per IP)
/imageShared pool — up to 5/min for OpenAI models, 10/min for Gemini models
/tts20 requests / minute (per IP)
/transcribe15 requests / minute (per IP)
All other routes100 requests / minute (per IP)

Because /image capacity is shared across all users rather than tied to your IP, a busy moment for Apiarium overall — not just your own usage — can occasionally result in a 429 on that endpoint. Retry after a few seconds.

/llm, /tts, and /transcribe responses include standard rate limit headers so you can track your usage:

RateLimit-Limit: 30
RateLimit-Remaining: 27
RateLimit-Reset: 42  // seconds until the window resets

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
403Model not available on your plan
429Rate limit exceeded
500Internal server error

Example error response:

{
  "error": "Model \"claude-haiku\" is not available on your plan (starter). Upgrade to access more models.",
  "available_models": ["gpt-4o-mini"]
}

Provider errors

When a request fails on the AI provider's side (rate limits, overload, downtime), the response includes error_class and provider fields so you can branch your retry logic on the failure type, not on which provider was called.

rate_limited429Provider rate limit hit — retry with backoff
overloaded503Provider temporarily overloaded — retry later
quota_exceeded503Provider quota exhausted on our side
invalid_request400Request rejected by the provider
authentication_error502Provider auth failed — not your fault, contact us
server_error502Provider had an internal error

Example provider error response:

{
  "error": "AI provider error. Please try again.",
  "error_class": "overloaded",
  "provider": "anthropic"
}

LLM — Text Generation

POST/llm

Generate text using GPT, Claude, or Gemini models. Send a list of messages in chat format and receive a completion. Streaming is not supported — the full response is returned at once.

Available models

gpt-4o-miniFree, Starter, Pro
gpt-4oPro only
claude-haikuStarter, Pro
claude-sonnetPro only
geminiPro only

gemini maps to Google's Gemini 3.5 Flash, their current flagship model — comparable in capability to gpt-4o and claude-sonnet, which is why it sits alongside them as a Pro-only option.

Parameters

PARAMTYPEREQDESCRIPTION
messagesarrayYesArray of message objects with role (user/assistant/system) and content. Max 20 messages, 10,000 chars each.
modelstringNogpt-4o-mini, gpt-4o, claude-haiku, claude-sonnet, or gemini. Default: gpt-4o-mini
max_tokensnumberNoMaximum tokens to generate. Range: 1–4096. Default: 1024. Applies to all models.
temperaturenumberNoRandomness of the response. GPT and Gemini models accept 0–2. Claude models accept 0–1 (values above 1 are clamped). Default: 1.0.

Example

curl
javascript
python
curl -X POST https://api.apiarium.dev/llm \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "messages": [
      { "role": "system", "content": "You are a helpful assistant." },
      { "role": "user", "content": "Write a tagline for a coffee brand" }
    ],
    "model": "claude-haiku",
    "max_tokens": 256,
    "temperature": 0.7
  }'

Response

{
  "content": "Brew the moment.",
  "model": "claude-haiku",
  "credits_used": 2,
  "credits_remaining": 9998,
  "tokens": { "input": 12, "output": 9 }
}

Image Generation

POST/image

Generate images from a text prompt using OpenAI or Google's image models. Free and Starter plans use gpt-image-1 by default. Starter also unlocks Gemini's gemini-flash-image. Pro plans get access to every model, including the higher-quality gpt-image-2 and gemini-pro-image. Images are returned as a public URL.

Note: /image has a shared capacity limit across all Apiarium users (see Rate Limits above), since it's bound by our upstream providers' account-wide throughput rather than per-user traffic. You may occasionally see a 429 here even under normal usage — retry after a few seconds.

Available models

gpt-image-1Free, Starter, Pro50–200 (by quality)
gemini-flash-imageStarter, Pro90
gpt-image-2Pro only200
gemini-pro-imagePro only220

gemini-flash-image (Nano Banana 2) is optimized for speed and high-volume generation. gemini-pro-image (Nano Banana Pro) is Google's highest-quality model, better suited for complex prompts, accurate text rendering, and multi-turn edits.

Parameters

PARAMTYPEREQDESCRIPTION
promptstringYesText description of the image to generate. Max 4,000 characters.
modelstringNogpt-image-1, gpt-image-2, gemini-flash-image, or gemini-pro-image. Availability depends on your plan. Default: gpt-image-2 on Pro, gpt-image-1 on Free/Starter.
sizestringNo1024x1024 (default), 1536x1024, 1024x1536, or auto. Only applies to gpt-image-1 / gpt-image-2.
qualitystringNolow, medium (default for gpt-image-1), or high (default for gpt-image-2). Only applies to OpenAI models. For gpt-image-1, cost varies by quality: 50/100/200 credits.
output_formatstringNopng (default), jpeg, or webp. Only applies to OpenAI models — Gemini models always return png.
backgroundstringNoopaque (default) or transparent. Only applies to OpenAI models.

Example

curl
javascript
python
curl -X POST https://api.apiarium.dev/image \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A futuristic city at sunset, digital art",
    "model": "gemini-flash-image"
  }'

Response

{
  "url": "https://saduxychstwvxqgevqxw.supabase.co/storage/v1/object/public/images/abc123.png",
  "model": "gemini-flash-image",
  "output_format": "png",
  "credits_used": 90,
  "credits_remaining": 9910
}

Some parameters only apply to specific models. If you send a parameter unsupported by the model you chose (e.g. quality with a Gemini model), the request still succeeds — the response includes a warnings field so you know it was ignored, instead of failing silently:

{
  "url": "https://.../image.png",
  "model": "gemini-flash-image",
  "credits_used": 90,
  "credits_remaining": 9910,
  "warnings": ["The following parameters are not supported by gemini-flash-image and were ignored: quality"]
}

Text to Speech

POST/tts

Convert text to natural-sounding audio using OpenAI or Gemini voices. Maximum input: 4,096 characters per request.

Available models

tts-1Free, Starter, Pro18 / 1,000 chars
gemini-ttsFree, Starter, Pro44 / 1,000 chars

gemini-tts (Gemini 3.1 Flash TTS) is a premium option with natural-language style control — you can direct tone, pace, accent, and emotion (e.g. [whispers], [excited]) directly in the input text, and it supports 70+ languages and up to 2 distinct speakers in a single request. tts-1 (OpenAI) is the faster, lower-cost default with 6 fixed voices.

Note: gemini-tts only supports wav and pcm as response_format — it returns raw audio natively and doesn't go through OpenAI's format conversion. Use tts-1 if you need mp3, opus, aac, or flac.

Parameters

PARAMTYPEREQDESCRIPTION
textstringYesThe text to convert to speech. Max 4,096 characters. For gemini-tts, you can also include style tags like [whispers] or [excited] inline.
modelstringNotts-1 or gemini-tts. Default: tts-1
voicestringNoFor tts-1: alloy (default), echo, fable, onyx, nova, shimmer. For gemini-tts: one of 30 voices (default: Kore) — see Google's voice library for the full list and styles.
speednumberNoPlayback speed. Range: 0.25–4.0. Default: 1.0. tts-1 only.
response_formatstringNotts-1: mp3 (default), opus, aac, flac, wav, or pcm. gemini-tts: wav (default) or pcm only.

Example

curl
javascript
python
curl -X POST https://api.apiarium.dev/tts \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text": "Hello from Apiarium", "model": "tts-1", "voice": "nova", "speed": 1.0, "response_format": "mp3"}' \
  --output audio.mp3

Example — gemini-tts with style control

curl
javascript
python
curl -X POST https://api.apiarium.dev/tts \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text": "[excitedly] Hello from Apiarium!", "model": "gemini-tts", "voice": "Puck"}' \
  --output audio.wav

Response

Returns a binary audio stream. The Content-Type header reflects the requested format. Headers include:

Content-Type: audio/mpeg
X-Credits-Used: 18
X-Credits-Remaining: 9982

Transcription

POST/transcribe

Transcribe audio to text using Whisper. Send an audio file as multipart/form-data. Costs 10 credits per minute of audio. Supports 50+ languages including English, Spanish, French, German, Portuguese, Italian, Japanese, Chinese, and more.

Parameters

PARAMTYPEREQDESCRIPTION
filefileYesAudio file (mp3, mp4, wav, m4a, webm). Max 25MB.
languagestringNo2-letter ISO language code (e.g. en, es, fr). Providing this improves accuracy and speed. Auto-detected if omitted.
promptstringNoOptional context to improve transcription accuracy. Useful for domain-specific terms, names, or acronyms. Max 224 tokens.

Example

curl
javascript
python
curl -X POST https://api.apiarium.dev/transcribe \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "file=@audio.mp3" \
  -F "language=en" \
  -F "prompt=Apiarium, Node.js, API"

Response

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