ReferenceOpenAI-compatible subset

The Aporion API

Call the models running on your own computers with the OpenAI clients you already use. Two endpoints: the models list and chat completions, with streaming.

This page describes the API as built in this release. Anything it does not list is not supported.

Base URL

https://aporion.sh/v1

Every request is answered by a model on one of the computers in your account. It is never sent to another account's device or to a paid provider, and there is no fallback.

Authentication

Create an API key in the web app, under API keys. The key is shown once, when you create it; Aporion keeps only a keyed hash of it. Send it as a bearer token:

Authorization: Bearer apr_…
Scopes
ScopeAllows
models:readGET /v1/models
chat:writePOST /v1/chat/completions
  • A key can be restricted to some of your devices. It then never reaches the others.
  • A key can expire after 1 to 365 days, or never.
  • Revoking a key takes effect on the next request.
  • An account can have up to 20 active keys.

GET/v1/models

The models installed on your devices that can take a request now, and that the key may use. Each id is a catalog id, such as qwen3-4b; aporion.devices lists the devices that have it.

Example response
{
  "object": "list",
  "data": [{
    "id": "qwen3-4b",
    "object": "model",
    "created": 1793790000,
    "owned_by": "you",
    "aporion": { "devices": [{ "id": "…", "name": "Desk PC", "variant": "q4_k_m", "loaded": true, "contextLength": 8192 }] }
  }]
}

POST/v1/chat/completions

Creates a reply from a model on one of your devices. Without stream, the answer is one chat.completion object.

Supported fields
FieldNotes
modelRequired. A model id from GET /v1/models.
messagesRequired. Roles system, user and assistant (developer is read as system). Content is text, or an array of text parts. Up to 200 messages and 200,000 characters.
streamtrue for server-sent events.
stream_options.include_usageWith stream: a last chunk with token counts.
max_tokens, max_completion_tokensAt most 8,192. A larger value is lowered to 8,192, and the answer says so in X-Aporion-Max-Tokens.
temperatureFrom 0 to 2.
top_pFrom 0 to 1.
stopA string, or up to 4 strings of up to 64 characters.
seedA number from 0 to 2,147,483,647.
aporion.deviceOptional. The device to use: see "Choosing a device" below.
Response headers
HeaderMeaning
X-Request-IdOn every answer, errors included. Usage records carry the same id.
X-Aporion-DeviceThe id of the device that generated the reply.
Retry-AfterSeconds to wait, on some 429 and 503 answers.

Streaming

With "stream": true the answer is text/event-stream. It starts once a device has taken the request, so a request no device picks up is still a plain HTTP error. Each event is a chat.completion.chunk:

  • The first chunk carries "role": "assistant".
  • Text arrives in delta.content. Models that think out loud also send delta.reasoning_content.
  • The last chunk carries finish_reason: stop or length. With include_usage, a chunk with usage and no choices follows.
  • The stream ends with data: [DONE]. A comment line keeps quiet connections open every 15 seconds.
  • If the device fails after the stream has started, the stream ends with an error object instead of [DONE].

Choosing a device

By default Aporion routes each request to one of your computers that is online, accepts remote requests, is not paused in your account and has the model. It prefers one where the model is already loaded, then the one running the fewest requests.

To pin a device, send its id, from aporion.devices in the models list, in a header or in the body:

Header
X-Aporion-Device: <device id>
Body
"aporion": { "device": "<device id>" }

A pinned device that cannot take the request fails with the reason. The request is never moved to another device. One request runs on one device: several devices do not jointly run one model.

Not supported

A request that uses any of these is refused with 400 and the code unsupported, never silently ignored:

  • Tools and function calls
  • Images and audio
  • n greater than 1
  • response_format other than text
  • logprobs
  • frequency_penalty and presence_penalty
  • logit_bias
  • Predicted outputs and web search

Other endpoints, such as embeddings, legacy completions, files or images, answer 404 with the code not_found.

Errors

Errors are shaped like OpenAI's, so client libraries raise them as usual:

Error body
{
  "error": {
    "message": "…",
    "type": "rate_limit_error",
    "code": "rate_limit_exceeded",
    "param": null
  }
}
Status codes
StatusTypeWhen
400invalid_request_errorThe body is not valid JSON, a field is out of range, something is not supported, or the conversation is too long for the model.
401authentication_errorThe API key is missing, wrong, revoked or expired.
403permission_errorThe key does not have the scope this endpoint needs.
404invalid_request_errorThe model is not installed on any of your devices, the device is not in your account, or the endpoint does not exist.
409device_errorRemote requests are off on that computer, or it is paused in your account.
413invalid_request_errorThe body is larger than 256 KiB.
429rate_limit_errorToo many requests, or your devices with the model are busy.
502device_errorThe device could not answer.
503device_errorNo device can take the request: none is set up, they are offline, or none picked it up in time.
504timeout_errorThe request took too long, or the device stopped responding while answering.

Limits

Limits
Request body256 KiB
Requests per API key60 per minute
Requests per account120 per minute, app and API together
Requests running at once4 per account, app and API together
Time per request280 seconds
Waiting for a device30 seconds
Reply length8,192 tokens

Privacy

API requests are not end to end. TLS ends at the gateway on aporion.sh, which reads your request in memory, seals it to the chosen device's key and opens the device's reply to stream it back to you. For end-to-end encryption from your browser to your computer, use the chat in the web app.

  • The database holds only ciphertext job rows, and they lose their sealed payloads when the request ends.
  • Usage records keep the time, key id, device, model, token counts, duration, status and request id for 30 days. They never contain prompts or outputs.
  • Your computer connects out to aporion.sh; nothing at home listens on the network.

Examples

curl
curl https://aporion.sh/v1/chat/completions \
  -H "Authorization: Bearer $APORION_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen3-4b",
    "stream": true,
    "messages": [{"role": "user", "content": "Hello"}]
  }'
Python, with the openai package
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://aporion.sh/v1",
    api_key=os.environ["APORION_API_KEY"],
)
stream = client.chat.completions.create(
    model="qwen3-4b",
    messages=[{"role": "user", "content": "Hello"}],
    stream=True,
)
for chunk in stream:
    print(chunk.choices[0].delta.content or "", end="")
JavaScript, with the openai package
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://aporion.sh/v1",
  apiKey: process.env.APORION_API_KEY,
});

const stream = await client.chat.completions.create({
  model: "qwen3-4b",
  messages: [{ role: "user", content: "Hello" }],
  stream: true,
});
for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}