Skip to main content
The LLM models speak the OpenAI Chat Completions API at 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

string
required
One of the ids above.
array
required
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.
integer
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.
boolean
true returns live server-sent events.
object
text, json_object, or json_schema with a json_schema object that has a name.
string
Passed to the model as its reasoning effort.
various
As in the OpenAI API. metadata values are strings.
integer
Only 1.
The API refuses any other field, tools and stop included, with HTTP 422 invalid_request before it reserves any cost. The request body is at most 2 MiB.

Answer

  • reasoning_content is present when the model reports its reasoning.
  • finish_reason is stop, or length when the answer reached max_completion_tokens.
  • The model field in every answer is the public id you sent.

Streaming

With "stream": true, the answer arrives as server-sent events, in this order:
  1. chat.completion.chunk events with delta.content, and delta.reasoning_content when the model reports it.
  2. One chunk with finish_reason.
  3. One chunk with usage and an empty choices array.
  4. 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. stream can 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-Key header. The API generates one when you send none.
Send a key whenever a client can retry, so a retry never starts a second job. When every replica serving the model is busy, the POST answers HTTP 429 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 to https://api.abstract.inc/v1 and read the key from ABSTRACT_API_KEY.
Run a program with the key in its environment only, for example ABSTRACT_API_KEY="$(abstract token)" python answer.py.

Usage

A finished completion carries usage 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.