OpenAI-compatible API

Realtime chat, embeddings and decisions with the OpenAI SDK.

What it is

https://oai.anex.sh/v1 answers OpenAI-compatible requests right away: chat completions (streamed or not), embeddings, typed decisions and a model list. Point any OpenAI SDK at it with an API key from the console's Keys page, sent as Authorization: Bearer <api-key>. Requests bill from the same credit balance as batch jobs. The same host runs files of requests through an OpenAI-compatible batch API.

from openai import OpenAI

client = OpenAI(base_url="https://oai.anex.sh/v1", api_key="<api-key>")
reply = client.chat.completions.create(
    model="gemma4-12b",
    messages=[{"role": "user", "content": "Name three rivers in Europe."}],
    max_tokens=200,
)
print(reply.choices[0].message.content, reply.usage)

Models

modelendpointtakescontext
gemma4-12b/v1/chat/completionstext, images, audio up to 30 s, video up to 60 s32,768
nemotron-3-nano-omni-30b/v1/chat/completionstext, images, audio up to 40 minutes, video up to 60 s32,768
qwen3-vl-embedding-2b/v1/embeddingstext, images, video up to 120 s; 64 to 2048 dimensions32,768
laya/v1/systemonea text state and typed questions512 per question, 1,024 multilingual

GET /v1/models lists the chat and embedding models with their prices, context length, supported parameters, media formats and limits. It is public: no API key needed. GET /v1/models/{model} returns one model's entry from that list (the OpenAI SDK's models.retrieve), and 404 for a model not on it. laya is not on that list: its price is in the realtime price table and its limits under Decisions.

Chat completions

POST /v1/chat/completions takes the OpenAI request body.

Parameters

parametervalues
temperature0 to 2
top_p0 to 1
max_tokens or max_completion_tokensup to 32,768
stopup to 4 sequences
seeda whole number, -263 to 263-1
frequency_penalty, presence_penalty-2 to 2
logprobstrue or false
top_logprobs0 to 20; above 0 needs logprobs
top_k0 or more; 0 is off
min_p0 to 1
repetition_penaltyabove 0, up to 2
response_formattext, json_object, or json_schema with a schema
prompt_cache_keya string, up to 512 characters
n1

Also: tools, reasoning and reasoning_effort, and chat_template_kwargs as in batch input files. Roles: system, developer, user, assistant, tool.

A value outside these ranges, an unknown field (such as logit_bias, ignore_eos or min_tokens) or role, or n above 1 is refused with a 400 that names it.

Generated text and video carry machine-readable marks that identify them as AI-generated, as the EU AI Act requires. We measured marked and unmarked output side by side, in English and Czech, and the marks did not change its quality. Where text is marked, the temperature is at least 0.01, so a temperature of 0 may run at 0.01, and top_p, top_k and min_p are held to the same minimum of randomness (top_p at least 0.01, top_k at least 2, min_p at most 0.99). Embeddings and decision answers are not marked. Anyone can check text or a video for our marks at POST https://api.anex.sh/batch/v1/detect/text and POST https://api.anex.sh/batch/v1/detect/video; text needs about 1,000 tokens for a reliable answer. See checking content for our marks. A watermarking field is refused with a 400.

Ignored:user, store, metadata, service_tier, safety_identifier, provider, models, route, transforms, plugins, usage, and structured_outputs as true or false. The same seed can still give a different answer, so /v1/models leaves it out.

Tool calls

tools, tool_choice and parallel_tool_calls work the same on both chat models. finish_reason: "tool_calls" always comes with tool_calls.

tool_choiceanswerfinish_reason
"auto" (default)the model decides
"required"one or more tool calls; one with parallel_tool_calls: false"tool_calls"
{"type": "function", "function": {"name": "get_weather"}}a call to that function, arguments per its schema"stop"
"none"text only, no thinking whatever reasoning says; earlier tool calls and results are still read
  • A forced call ("required" or named) overrides response_format. Cut off by the output cap, it comes back as partial text in content with finish_reason: "length"; with thinking on, leave room in max_tokens.
  • With a named function every tool stays in the prompt, so give similar tools distinct names and descriptions.
  • With "none", nemotron-3-nano-omni-30b adds up to about 80 tokens of instruction to the system prompt, counted in prompt_tokens and the context, and drops the tools from the prompt until messages holds a tool call or result. gemma4-12b drops them.
  • Naming a function missing from tools, or asking for a call without tools, is a 400.

Log probabilities

They cover every generated token except the end-of-turn token and a leading newline the answer drops. With thinking off they match content token for token; with thinking on they include the thinking and its markers, so logprobs with reasoning.exclude is a 400 naming both.

Prompt caching

Requests with the same cache key use the same prompt cache when possible: a repeated prefix bills at the cached-input price and the answer starts sooner. Use one key per conversation or shared document. Without one, requests that open the same way (system prompt, tools, start of the first user message) are grouped for you. The key is in supported_parameters on /v1/models.

Context and time limit

The context is 32,768 tokens. A request that does not fit is a 400 context_length_exceeded giving the context and, when known, the tokens asked for (messages and completion; the messages' count may read "at least" a number). A non-streamed answer carries usage, and past 280 seconds, media downloads included, ends in a 504: stream long answers.

Streaming

Send "stream": true for server-sent events (SSE) in the OpenAI chunk format, ending with data: [DONE].

  • "stream_options": {"include_usage": true} adds a final usage chunk.
  • While the model is silent, a : keep-alive comment comes every 10 seconds.
  • A failure mid-answer ends with a chunk carrying an error object and finish_reason: "error".
  • Closing the connection stops the answer; you pay for the tokens generated so far.

Images, audio and video in chat

Send image_url, input_audio and video_url parts, by URL or base64. Audio by URL goes in input_audio.data or an audio_url part: {"type": "audio_url", "audio_url": {"url": "https://..."}}. At most 2 images, 1 audio clip and 1 video per request; sizes are in the media limits.

mediumaccepted media types
imageimage/png, image/jpeg, image/webp, image/gif, image/bmp, image/tiff
audioaudio/wav, audio/mpeg (MP3), audio/mp4 (M4A), audio/aac, audio/ogg, audio/opus, audio/flac, audio/aiff
videovideo/mp4, video/webm, video/quicktime (MOV), video/x-matroska (MKV), video/x-msvideo (AVI)

The format comes from input_audio.format, a data URI or the URL's extension, checked against the content; any other is a 400. Embeddings take the same image and video formats. /v1/models names only PNG, JPEG, WebP, GIF, WAV, MP3, MP4 and WebM; this table is the full list.

Reasoning

nemotron-3-nano-omni-30b thinks by default. gemma4-12b does not, unless you send enabled, an effort or a max_tokens.

sendeffect
"reasoning": {"enabled": false}thinking off (true: on)
{"effort": ...} or top-level reasoning_effortnone is off; minimal, low, medium, high, xhigh turn it on, uncapped
{"enabled": true, "max_tokens": 1000}gemma4-12b only: caps thinking at 1,000 tokens, including a closing note of about 24 tokens; not applied beside a response_format. nemotron-3-nano-omni-30b ignores max_tokens.
{"exclude": true}leaves the thinking text out; not with logprobs

Returned thinking is in reasoning_content and bills as output tokens. reasoning_effort is listed under supported_parameters in /v1/models.

Embeddings

POST /v1/embeddings is the OpenAI embeddings call.

parametervalues
inputa string, up to 128 strings, or content arrays; token ids are a 400
dimensions64 to 2048
encoding_formatfloat (default) or base64 (little-endian float32)

A content array is one input, embedded into one vector, made of text, image_url and input_video parts ({"type": "input_video", "input_video": {"data": "<base64 or URL>", "format": "mp4"}}):

client.embeddings.create(
    model="qwen3-vl-embedding-2b",
    input=[[
        {"type": "text", "text": "a red bicycle"},
        {"type": "image_url", "image_url": {"url": "https://example.com/bike.jpg"}},
    ]],
    dimensions=1024,
)
  • Up to 16 content arrays and 16 image and video parts per request; 4 images and 1 video per array.
  • Text: up to 262,144 characters per input, 2,097,152 in all.
  • Audio and file parts are refused. Sizes are in the media limits.
  • Video is read at 1 frame per second, each frame at up to 156,800 pixels, 81 tokens a frame.
  • usage.prompt_tokens includes the media tokens; each image and second of video adds a fee (how media is billed).

Media limits

  • A request body is at most 32 MiB, so an item sent inline as base64 can be up to about 24 MiB. Larger media goes by URL.
  • By URL, each image may be up to 20 MiB, each video up to 32 MiB, and each audio clip up to 20 MiB on gemma4-12b and 32 MiB on nemotron-3-nano-omni-30b, with 64 MiB of media in one request.
  • Each URL is downloaded once, by our media fetcher.
  • A media URL must answer with the file itself: a redirect (an HTTP 3xx answer, as from a short link or some CDNs) is not followed and the request is refused with a 400, so send the final URL. This holds for chat and embeddings alike.
  • All of a request's URLs must arrive within 300 seconds, and an image within 10; past that the request answers 400.
  • GET /v1/models lists, per model and medium, the largest item every route accepts.

Decisions

POST /v1/systemone answers typed questions about a state, with a probability per option. The request and answer have the same shape as on the realtime endpoint; see realtime decisions. The model reads each question together with the state in a window of 512 tokens for English and other Latin-script text, or 1,024 when it reads the text with its multilingual checkpoint (other scripts, or a lang naming another language). On this host a state too long for a question is refused with a 400 that names the question and says how many tokens to cut. Batches, and the realtime API on api.anex.sh, cut such a state to the window instead. A question the model cannot answer as written (an unknown type, no instructions, yes-or-no criteria keyed other than true and false) is refused with a 422 that names it.

As in a batch decision row, a request carries model, state, questions and an optional lang; any other field (a temperature, say) is refused with a 400 that names it. The answer carries, per question, type, the answer itself (choice, noul or score, with legend for a score), probabilities, confidence and answer_confidence, plus usage and routing with its model and reason. Batch results from this host carry the same fields.

Prices

Requests on this host bill at the realtime prices and batches at the batch prices, from the same credit balance and at the same prices as on api.anex.sh. GET /v1/models returns the same realtime figures.

Images, audio and video add a fee to their tokens: how media is billed.

Limits and status codes

  • 8 requests in flight per organization, shared with the realtime API on api.anex.sh (ask support for more), and a per-model limit listed in /v1/models (laya: 16).
  • Past either: an immediate 429 with Retry-After, never a queue.
  • When traffic rises fast, a model can answer 429 below its limit for a few minutes; retry after Retry-After.
codemeaning
400malformed request, unsupported value or media part, max_tokens above 32,768, or over the context (context_length_exceeded)
400media whose header claims more than its content holds (media_length_mismatch) or that cannot be read (media_unreadable); not run and not billed
401missing, unknown or revoked API key
402no credit balance left, or the organization's credit limit is reached
403organization suspended (org_suspended); contact support@anex.sh
404unknown model or path
413request body over 32 MiB, or media over its size limit
422a decision question that cannot be answered as written (/v1/systemone)
429concurrency limit reached; retry after Retry-After
502the model failed while answering; retry
503model unavailable (service_unavailable); retry after Retry-After
504non-streamed answer over 280 seconds; stream instead

Errors use the OpenAI shape, {"error": {"message": ..., "type": ..., "code": ...}}, with code always a string: the name in the table, else invalid_request, not_found, rate_limit_exceeded, upstream_error and the like. A malformed request (a field of the wrong type, out of range, missing or unknown) or a body that is not a JSON object is a 400 invalid_request naming the field as you wrote it, e.g. messages[0].content must be a string or an array of content parts.

Your data

We do not store the prompts, media or answers of realtime requests, and we never use them to train models. For billing we record each request's time, model, token counts, media size or length, status and duration. Requests are served from North America (the United States, Canada and Mexico). Files you send to the batch API are stored for the times given there.

Batch API

The same host serves an OpenAI-compatible batch API. Upload a JSONL file of requests, create a batch from it, poll the batch, and download the results. Any OpenAI SDK works with the base URL https://oai.anex.sh/v1 and your API key. Batches bill at the batch prices, the same as a batch job on api.anex.sh.

import time
from openai import OpenAI

client = OpenAI(base_url="https://oai.anex.sh/v1", api_key="<api-key>")
with open("requests.jsonl", "rb") as fh:
    f = client.files.create(file=fh, purpose="batch")
batch = client.batches.create(input_file_id=f.id,
                              endpoint="/v1/chat/completions",
                              completion_window="24h")
while batch.status not in ("completed", "failed", "expired", "cancelled"):
    time.sleep(60)
    batch = client.batches.retrieve(batch.id)
print(batch.status, batch.request_counts)
if batch.output_file_id:
    client.files.content(batch.output_file_id).write_to_file("output.jsonl")
if batch.error_file_id:
    client.files.content(batch.error_file_id).write_to_file("errors.jsonl")

Batch input file

One request per line, each with custom_id (a non-empty string, unique in the file), method (POST), url and body. Every line of a file names the same url and the same body.model: a batch runs one model on one endpoint, /v1/chat/completions, /v1/embeddings or /v1/systemone. Save the file as UTF-8 without a byte order mark.

{"custom_id":"row-1","method":"POST","url":"/v1/chat/completions","body":{"model":"gemma4-12b","messages":[{"role":"user","content":"Say hello in French."}],"max_tokens":200}}

Each chat request keeps its own output cap, max_tokens or max_completion_tokens. A request without one gets 4,096 tokens, or the model's maximum output if that is lower. From a chat request's body, messages, response_format, chat_template_kwargs, reasoning and the output cap are used, as described for batch input files, along with the sampling fields temperature (0 to 2), top_p (0 to 1, as on the realtime route), seed and stop (up to 4 strings). Other fields, including n, are not carried through. Embedding requests take input and dimensions, with encoding_format left out or "float". Decision requests take state, questions and lang.

reasoning works per request. {"enabled": false} or {"effort": "none"} turns thinking off. {"effort": "minimal" | "low" | "medium" | "high" | "xhigh"} turns it on. Neither chat model has effort levels of its own, so every level other than "none" thinks the same way. {"max_tokens": N} caps the thinking at N tokens, including the short note that closes it, on gemma4-12b (nemotron-3-nano-omni-30b ignores the cap); the cap always leaves 64 tokens of the request's output cap for the answer, and a larger N is lowered to fit. A request with a response_format thinks without a budget. {"exclude": true} leaves the reasoning text out of the result. A request's own chat_template_kwargs.enable_thinking or chat_template_kwargs.reasoning_effort wins over reasoning.

A file can be up to 1 GiB and 10,000,000 requests. The upload checks every line and refuses the file with the line number of the first problem. A line too long to hold its media inline is refused with a 413 that says how large media may be; send larger images, audio and video by URL. A repeated custom_id and a malformed message are found when the batch runs, and fail the batch.

Each organization may upload 2 files at a time. Past that, or while the service is busy with other uploads, an upload is answered 429 with a Retry-After header. An upload that sends nothing for 60 seconds, averages under 256 KiB/s after its first minute, or takes longer than 30 minutes is stopped with a 408; send it again.

Batch endpoints

POST /v1/files
Upload a file, as multipart form data with purpose=batch and the file in file.
GET /v1/files
List your files, newest first, with purpose, limit, order and after.
GET /v1/files/{file_id}
A file's details.
GET /v1/files/{file_id}/content
Download a file, including a batch's output and error files.
DELETE /v1/files/{file_id}
Not offered: answers 405 (file_deletion_not_supported). Files are deleted on the schedule in Batch results; to delete a batch's data sooner, delete its job in the console.
POST /v1/batches
Create a batch: input_file_id, endpoint (the url of the file's requests), completion_window ("24h") and optional metadata (up to 16 pairs, keys up to 64 and values up to 512 characters).
GET /v1/batches/{batch_id}
A batch's status, request counts and file ids, and usage: the input, cached input and output tokens of the requests finished so far (null until the first ones finish).
POST /v1/batches/{batch_id}/cancel
Cancel a batch. Requests that already finished are delivered and billed.
GET /v1/batches
List your batches, newest first, with limit (up to 100) and after.

A batch's anex_job_id is the same batch as a job in the console. If creating a batch answers with a 500, list your batches before you retry: the batch may exist, and a retry creates a second one.

Batch price and approval

A batch is quoted when it is created. The quote prices the output of every chat request at the largest output cap in the file (a request without a cap counts at its default), so the output part of a quote is the number of requests times that cap. The bill counts the tokens each request really used. The quote and the bill are never below the model's minimum job price.

A batch is approved as soon as it is priced when your credit balance or your organization's credit limit covers the quote, and then it starts. If it cannot be approved yet (the balance or the credit limit does not cover the quote, the organization is suspended, or the approval check is briefly unavailable), the batch stays in validating and approval is retried every few minutes. It starts once the cause is resolved, for example after a top-up, and expires without a charge if that has not happened 24 hours after it was created.

Batch status

validating
The file is being checked and priced, or the batch is waiting to be approved (see Batch price and approval).
in_progress
The requests are running.
finalizing
The output and error files are being written.
completed
Every request has a result in the output or the error file.
failed
The batch could not run; errors says why.
cancelling, cancelled
The batch was cancelled; requests that finished first are in its files.
expired
The batch had not finished 24 hours after it was created, so it was stopped. Requests that finished are in its files and are billed. A batch already in finalizing when its window closes completes.

Batch results

output_file_id holds the requests that succeeded and error_file_id the ones that failed, one line each in the result line format. Either is null when it would be empty. A chat result's message has the realtime answer's shape: its thinking text, when there is any, is in reasoning_content. Uploaded files are kept 7 days, and a batch's output and error files 30 days after the batch ends. Downloading a file after that answers 404 with a message that says it was deleted.

Batch status codes

Errors from these routes use the OpenAI shape, {"error": {"message", "type", "param", "code"}}.

codemeaning
400a field of the request is invalid, a line of the file is invalid, the file mixes models or endpoints, or a request's cap is above the model's maximum output (param input_file_id); a model that is unknown or not offered for batch (model_not_found); an organization with EU data routing on (unsupported_data_residency), which uses the batch API instead
401missing, unknown or revoked API key
402no credit balance left, at upload or when creating a batch, or the organization's credit limit is reached when creating a batch
403organization suspended (org_suspended); contact support@anex.sh
404unknown file or batch, or a file whose content was deleted
405deleting a file (file_deletion_not_supported)
408the upload was too slow or stalled (upload_timeout)
409creating a batch from an input file that can no longer be used (param input_file_id); cancelling a batch that has finished or is finalizing
413the file is over 1 GiB, or a line is too long to hold its media inline
429too many uploads in progress (too_many_uploads), or creating a batch while 100 batches of the organization are in validating; retry after Retry-After seconds
503the batch routes are paused for maintenance; retry later