Documentation

API reference

apillms exposes one REST API for language, image, video and voice models. It follows the OpenAI and Anthropic wire formats, so existing SDKs work by changing the base URL.

https://apillms.com/v1
New here? Create an account, copy your key from Dashboard → API keys, and run the first example below.

Authentication

Every request needs your secret key. Send it in either header:

Authorization: Bearer sk-apl-...
# or
x-api-key: sk-apl-...

Keep keys server-side. If a key leaks, roll it from the dashboard — the old key stops working immediately.

Models

Model IDs are listed live. Use them exactly as returned.

EndpointReturns
GET/v1/modelsAll models (OpenAI format). Filter with ?kind=chat or ?kind=image.
GET/v1/chat/modelsLanguage models with USD prices per 1M tokens and capabilities.
GET/v1/video/modelsVideo models with price per resolution / duration.

Browse them visually in the model catalog.

Chat Completions

POST/v1/chat/completions

OpenAI-compatible. Supports messages, temperature, max_tokens, tools, image inputs (on vision models) and stream.

from openai import OpenAI

client = OpenAI(base_url="https://apillms.com/v1", api_key="sk-apl-...")

res = client.chat.completions.create(
    model="claude-sonnet-5",
    messages=[
        {"role": "system", "content": "You are a concise assistant."},
        {"role": "user", "content": "Explain RAG in two sentences."},
    ],
)
print(res.choices[0].message.content)

Charged after the response by input and output tokens at the model's price. Empty or failed responses are free.

Streaming

Set "stream": true to receive Server-Sent Events. Token usage is included in the final chunk.

stream = client.chat.completions.create(
    model="gpt-6-astra",
    messages=[{"role": "user", "content": "Write a haiku about APIs."}],
    stream=True,
)
for chunk in stream:
    if chunk.choices:
        print(chunk.choices[0].delta.content or "", end="", flush=True)

Anthropic Messages

POST/v1/messages

Use the official Anthropic SDK with base_url="https://apillms.com" (the SDK appends /v1/messages).

import anthropic

client = anthropic.Anthropic(base_url="https://apillms.com", api_key="sk-apl-...")

msg = client.messages.create(
    model="claude-opus-5",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Review this function for bugs."}],
)
print(msg.content[0].text)

Responses

POST/v1/responses

For clients that use the OpenAI Responses API (for example recent n8n versions).

curl https://apillms.com/v1/responses \
  -H "Authorization: Bearer $APILLMS_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "gemini-3.8-flash", "input": "Hello"}'

Claude Code & Codex

One-line setup scripts configure the CLI to route through apillms. The dashboard shows these commands with your key filled in.

# Claude Code (optional: &main=claude-opus-5)
curl -fsSL "https://apillms.com/v1/setup-claudecode?key=sk-apl-..." | bash

# OpenAI Codex CLI (optional: &model=gpt-6-astra)
curl -fsSL "https://apillms.com/v1/setup-codex?key=sk-apl-..." | bash

Cursor, Cline, Continue, Aider and other tools: choose “OpenAI compatible”, set the base URL to https://apillms.com/v1 and paste your key.

Images

POST/v1/images/generations
FieldDescription
modelImage model ID from /v1/models?kind=image.
promptWhat to generate.
aspect_ratioOptional: 1:1, 16:9, 9:16, 4:3
size, qualityOptional, model-specific (see pricing in the model list).
image_urlsOptional array of public reference image URLs.
curl https://apillms.com/v1/images/generations \
  -H "Authorization: Bearer $APILLMS_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "IMAGE_MODEL_ID", "prompt": "a lighthouse at dusk, film photo", "aspect_ratio": "16:9"}'

The response contains data[0].url when ready, or an id to poll:

curl https://apillms.com/v1/images/jobs/JOB_ID -H "Authorization: Bearer $APILLMS_KEY"

Video

POST/v1/video/generate
curl https://apillms.com/v1/video/generate \
  -H "Authorization: Bearer $APILLMS_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "veo3.1-lite",
    "prompt": "slow dolly shot of a coffee cup, steam rising",
    "duration": 8,
    "resolution": "720p",
    "aspect_ratio": "16:9"
  }'

Video is asynchronous. Poll the job until status is completed; the file URL is in result.

curl https://apillms.com/v1/video/jobs/JOB_ID -H "Authorization: Bearer $APILLMS_KEY"
Credits are reserved when the job is created and refunded automatically if generation fails. For image-to-video, add img_url (or image_urls).

File upload

POST/v1/upload/media

Upload a local video (mp4, mov, webm) or audio (mp3, wav, ogg) file up to 100 MB as the raw request body. Returns a public url you can pass to other endpoints.

curl https://apillms.com/v1/upload/media \
  -H "Authorization: Bearer $APILLMS_KEY" \
  --data-binary @clip.mp4

Voice

GET/v1/voice-library
POST/v1/text-to-speech
# 1. Pick a voice
curl https://apillms.com/v1/voice-library -H "Authorization: Bearer $APILLMS_KEY"

# 2. Create speech
curl https://apillms.com/v1/text-to-speech \
  -H "Authorization: Bearer $APILLMS_KEY" \
  -H "Content-Type: application/json" \
  -d '{"voice_id": 9008, "text": "Welcome to apillms."}'

# 3. Fetch the result
curl https://apillms.com/v1/text-to-speech/JOB_ID -H "Authorization: Bearer $APILLMS_KEY"

The completed result includes audio_url, audio_duration and credits_used. Send srt instead of text to render subtitles on a timeline. Priced per character.

Balance & usage

EndpointDescription
GET/v1/accountBalance in credits and USD.
GET/v1/usage?days=1|3|7|30Credits, requests and tokens for the period, broken down by product.
GET/v1/jobs?limit=50&kind=&status=Recent requests with model, credits and status.

Errors

Errors use the OpenAI shape: {"error": {"message": "...", "type": "..."}}.

StatusMeaningCharged?
400Invalid parametersNo
401Missing or invalid API keyNo
402Insufficient credits — top up in BillingNo
404Unknown model or endpointNo
429Rate or concurrency limit — retry with backoffNo
5xxTemporary upstream failure — retryNo; media jobs refunded

Rate limits

Limits scale with usage to keep the platform fast for everyone. If you receive 429, retry with exponential backoff. Need higher limits for production? Email support@apillms.com.