BETA

Docs
Documentation

Create chat completion

POST/v1/chat/completions

Direct proxy to the upstream provider's OpenAI-compatible chat completions endpoint. The request body is forwarded as-is — every field your chosen model supports passes through unmodified.

Request body

model
required, string — a catalog id from GET /v1/models
messages
required, array — standard OpenAI message list
stream
optional, boolean — SSE token deltas when true
max_tokens
optional, number — capped server-side to what your balance can cover
…
any other field the target model supports (temperature, tools, response_format, reasoning_effort, …) is forwarded unmodified

cURL example

terminal
curl https://apily.pro/v1/chat/completions \
  -H "Authorization: Bearer apily_your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"model":"gpt-5.6-sol","messages":[{"role":"user","content":"ping"}]}'

Response

Mirrors the upstream provider's OpenAI-compatible response verbatim — a choices array and a usage object (prompt_tokens, completion_tokens, plus cache token fields when the model supports them). Streaming requests get the same shape split into SSE chunks, ending with data: [DONE].

Error responses

SymptomCauseFix
401 Missing API keyNo auth header was sent.Apily accepts Authorization: Bearer … and x-api-key: ….
401 Invalid API keyKey copied with stray spaces, truncated, or revoked.Copy the key whole from the API page in your Apily account, the apily_ prefix included.
403 Email not verifiedYour Apily account's email address isn't verified yet.Verify your email from the banner in the Apily app, then retry.
404 Model not foundThe model ID isn't in the Apily catalog.Copy the exact ID from GET /v1/models or the Models page in your account.
503 Model temporarily unavailableThe model exists, but no upstream provider is reachable right now.Retry in a moment — it usually recovers within a minute. Switch models if it keeps happening.
402 Insufficient balanceYour token balance can't cover the request's estimated cost.Top up your balance on the Billing page in your Apily account.
429 Too many requestsYour account sent more than 600 /v1/* requests in a minute — all of your API keys share one budget. The body is { error: { message, type: "rate_limit_error", code: "rate_limit_exceeded" }, retryAfterSeconds }.Wait the Retry-After header (or retryAfterSeconds) before retrying, and lower request concurrency.
502 Upstream errorThe upstream provider returned an unexpected error.Retry the request; try a different model if it persists.