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.
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.
| Endpoint | Returns |
|---|---|
GET/v1/models | All models (OpenAI format). Filter with ?kind=chat or ?kind=image. |
GET/v1/chat/models | Language models with USD prices per 1M tokens and capabilities. |
GET/v1/video/models | Video models with price per resolution / duration. |
Browse them visually in the model catalog.
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)
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://apillms.com/v1", apiKey: process.env.APILLMS_KEY });
const res = await client.chat.completions.create({
model: "claude-sonnet-5",
messages: [{ role: "user", content: "Explain RAG in two sentences." }],
});
console.log(res.choices[0].message.content);
curl https://apillms.com/v1/chat/completions \
-H "Authorization: Bearer $APILLMS_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-5",
"messages": [{"role": "user", "content": "Explain RAG in two sentences."}]
}'
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
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
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
| Field | Description |
|---|---|
model | Image model ID from /v1/models?kind=image. |
prompt | What to generate. |
aspect_ratio | Optional: 1:1, 16:9, 9:16, 4:3… |
size, quality | Optional, model-specific (see pricing in the model list). |
image_urls | Optional 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
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"
img_url (or image_urls).File upload
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
# 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
| Endpoint | Description |
|---|---|
GET/v1/account | Balance in credits and USD. |
GET/v1/usage?days=1|3|7|30 | Credits, 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": "..."}}.
| Status | Meaning | Charged? |
|---|---|---|
400 | Invalid parameters | No |
401 | Missing or invalid API key | No |
402 | Insufficient credits — top up in Billing | No |
404 | Unknown model or endpoint | No |
429 | Rate or concurrency limit — retry with backoff | No |
5xx | Temporary upstream failure — retry | No; 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.