POST https://api.abstract.inc/v1/chat/completions.
The model in the body selects the model.
Each model returns its answer in the HTTP response, or as server-sent events with
"stream": true.
GET /v1/models lists these ids.
Use an id exactly as written.
Request
At least one message.
role is system, developer, user or assistant. content is a
string or an array of text parts. A user message can also carry image_url parts, each a
base64 data: URL; any other URL is refused.A positive integer, at most 65,536, which is also the limit when you send none. It counts the
model’s reasoning as well as its answer, and the API holds its cost on your account until the call
ends.
max_tokens is accepted with the same meaning.tools and stop included, with HTTP 422 invalid_request before it reserves any cost.
The request body is at most 2 MiB.
Answer
reasoning_contentis present when the model reports its reasoning.finish_reasonisstop, orlengthwhen the answer reachedmax_completion_tokens.- The
modelfield in every answer is the public id you sent.
Streaming
With"stream": true, the answer arrives as server-sent events, in this order:
chat.completion.chunkevents withdelta.content, anddelta.reasoning_contentwhen the model reports it.- One chunk with
finish_reason. - One chunk with
usageand an emptychoicesarray. data: [DONE].
Read a completion later
GET /v1/chat/completions/{id} returns a completion your account created.
Only the account that created a completion can read it.
Any other account gets HTTP 404
not_found.
A completion from a retired model reads back from its kept answer, and one whose answer was never kept answers HTTP 404 not_found.
Idempotency-Key
Idempotency-Key is an optional header of 1 to 200 characters from A-Z a-z 0-9 _ . / : -.
- The same POST with the same key returns the same answer and never starts a second job.
streamcan differ between the two. - The same key with a different body returns HTTP 409
idempotency_conflict. - Use a new key for a new request.
- An accepted POST answers with an
Idempotency-Keyheader. The API generates one when you send none.
no_replica_free with a Retry-After header and reserves nothing. Wait that many seconds, then send it again with the same key.
OpenAI SDK
Set the base URL tohttps://api.abstract.inc/v1 and read the key from ABSTRACT_API_KEY.
ABSTRACT_API_KEY="$(abstract token)" python answer.py.
Usage
A finished completion carriesusage with prompt_tokens, prompt_tokens_details.cached_tokens and completion_tokens.
The completion is billed from those counts at the model’s per-million-token rates for input, cached input and output.
abstract.inc shows each model’s output rate.
The rates are fixed when you submit the request.