API quickstart
The chat endpoint is served through Alibaba Cloud Bailian (DashScope) models — Qwen 3.8 Flash and DeepSeek V4.1 Flash. This is a metered third-party relay, not a local or official Ajax service. Ajax is not available in this service.
The AjaxModel API is JSON over HTTPS, same origin as the site.
POST /v1/chat runs a metered chat call: the worker reserves the worst-case
token cost, calls the upstream provider, and settles actual usage — a provider failure
releases the reservation so failed calls are never charged.
Authentication
Create an API key in the console under API keys, then send it as a bearer token:
Authorization: Bearer ak_test_…
Browser sessions use cookies instead — API keys are for servers, scripts, and CI. Keys
carry the app:use scope. Chat requires a signed-in account or API key;
anonymous calls are rejected.
Chat
POST /v1/chat accepts {"messages": [...]} with an optional
model (qwen3.8-flash default, or
deepseek-v4.1-flash-1017) and max_output_tokens (1–2048). Other
fields — tools, images, extra URLs — are rejected.
curl -X POST https://app.ajaxmodel.dev/v1/chat \
-H "Authorization: Bearer ak_test_…" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: my-first-chat-001" \
-d '{"messages":[{"role":"user","content":"Hello"}]}'
const response = await fetch("/v1/chat", {
method: "POST",
headers: {
"authorization": "Bearer ak_test_…",
"content-type": "application/json",
"idempotency-key": crypto.randomUUID(),
},
body: JSON.stringify({
model: "qwen3.8-flash",
messages: [{ role: "user", content: "Hello" }],
}),
});
const { run } = await response.json();
History: GET /v1/chat?limit=10&cursor=…, GET /v1/chat/:id,
DELETE /v1/chat/:id. Usage is billed per token — $1 per 1M input / $4 per 1M
output tokens (draft).
OpenAI Chat Completions subset
POST /v1/chat/completions speaks a narrow Chat Completions subset for
existing SDKs: model (required, from the same whitelist),
messages, and an output cap via
max_completion_tokens (preferred) or the legacy max_tokens —
send one, not both. stream:false is accepted and ignored;
stream:true is refused — the endpoint is non-streaming only. Every other
field is rejected.
curl -X POST https://app.ajaxmodel.dev/v1/chat/completions \
-H "Authorization: Bearer ak_test_…" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3.8-flash",
"messages": [{"role":"user","content":"Hello"}],
"max_completion_tokens": 256
}'
The response is Chat Completions JSON — id, object,
created, model, choices[0].message.content,
finish_reason: "stop", and usage with total_tokens.
Idempotency-Key is optional here: without it every call is a new completion;
with it, a retry replays the stored completion with
x-idempotent-replay: true and is never charged twice.
Idempotency
Send an Idempotency-Key header (8–128 chars, letters, digits, -,
_) — it is required on POST /v1/chat and optional on
/v1/chat/completions. A retry with the same key returns the stored result
with x-idempotent-replay: true — never a second call or a second charge. Mint
a new key when the input changes.
Error codes
On small screens, scroll the table to read all error details.
| Code | Status | Meaning |
|---|---|---|
invalid_input |
400 | text missing, empty, or over the limit |
invalid_body |
400 | Request body is not a JSON object |
invalid_idempotency_key |
400 | Header fails the format rule |
invalid_cursor |
400 | List pagination cursor is malformed |
authentication_required |
401 | No session, API key, or guest cookie |
invalid_api_key |
401 | Bearer key is unknown or revoked |
scope_forbidden |
403 | Key lacks the required scope |
quota_exceeded |
402 | Insufficient prepaid balance |
invalid_model |
400 | Model is not on the served whitelist |
unsupported_field |
400 | Request carries a field outside the allowed set |
request_too_large |
413 | Body exceeds 16 KB |
provider_error |
502 | Upstream model call failed — credits were released |
provider_not_configured |
503 | Upstream key not configured |
daily_run_limit_reached |
429 | Plan's daily run cap reached |
run_not_found |
404 | Unknown or other-owned run id |
service_not_ready |
503 | Service gated off — no credits reserved or debited |
metering_unavailable |
503 | Usage accounting is down — retry |
metering_conflict |
503 | Usage accounting conflicted — retry |
Errors carry error.code, error.message, and
error.request_id — quote the request id when contacting
support.
Included Windows local kit
Either proposed $10 / $25 pack includes a Windows x64 installer and launcher for official Qwen3-4B Q4_K_M with llama.cpp. This is a separate local installation, not Ajax weights and not the online Bailian API. Running it does not consume online credits.
- After verified payment, open Account → Billing and download the kit. Download access lasts 365 days even if your online balance is spent.
-
Extract the ZIP. In PowerShell, run
./Install.ps1; it verifies the pinned official downloads. Allow 5 GiB free disk, at least 6 GiB free RAM, and a ~2.50 GB initial model download. Windows x64 / PowerShell 5.1+ only; CPU two threads, one 2048-token context slot. -
In the installed folder run
./Start.ps1. In a second PowerShell window there run./Chat.ps1. Each short message starts a new conversation. Stop with Ctrl+C or./Stop.ps1.
Prompts stay with the authenticated loopback runtime; there is no public tunnel or cloud fallback. Downloads contact GitHub and Hugging Face. No automatic service or update is installed. To remove it, stop it and delete only the chosen installation folder. Reinstall the same pinned version from the original extracted ZIP; install future versions into a separate folder.
A refund or dispute stops further downloads for that order. Existing local copies remain under the included Apache-2.0 / MIT licenses and are not remotely disabled. The purchase pays for online use and packaged setup/support, not exclusive ownership of open weights. Support covers installation/startup at support@ajaxmodel.dev; custom training, dedicated hosting, guaranteed model answers and future upgrades are not included. Do not send your local API key.
Real purchases remain closed pending payment approval and final Live checkout validation.