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_…
| Scope | Allows |
|---|---|
models:read | GET /v1/models |
chat:write | POST /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.
{
"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.
| Field | Notes |
|---|---|
model | Required. A model id from GET /v1/models. |
messages | Required. 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. |
stream | true for server-sent events. |
stream_options.include_usage | With stream: a last chunk with token counts. |
max_tokens, max_completion_tokens | At most 8,192. A larger value is lowered to 8,192, and the answer says so in X-Aporion-Max-Tokens. |
temperature | From 0 to 2. |
top_p | From 0 to 1. |
stop | A string, or up to 4 strings of up to 64 characters. |
seed | A number from 0 to 2,147,483,647. |
aporion.device | Optional. The device to use: see "Choosing a device" below. |
| Header | Meaning |
|---|---|
X-Request-Id | On every answer, errors included. Usage records carry the same id. |
X-Aporion-Device | The id of the device that generated the reply. |
Retry-After | Seconds 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 senddelta.reasoning_content. - The last chunk carries
finish_reason:stoporlength. Withinclude_usage, a chunk withusageand 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:
X-Aporion-Device: <device id>
"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
ngreater than 1response_formatother than textlogprobsfrequency_penaltyandpresence_penaltylogit_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": {
"message": "…",
"type": "rate_limit_error",
"code": "rate_limit_exceeded",
"param": null
}
}
| Status | Type | When |
|---|---|---|
| 400 | invalid_request_error | The body is not valid JSON, a field is out of range, something is not supported, or the conversation is too long for the model. |
| 401 | authentication_error | The API key is missing, wrong, revoked or expired. |
| 403 | permission_error | The key does not have the scope this endpoint needs. |
| 404 | invalid_request_error | The model is not installed on any of your devices, the device is not in your account, or the endpoint does not exist. |
| 409 | device_error | Remote requests are off on that computer, or it is paused in your account. |
| 413 | invalid_request_error | The body is larger than 256 KiB. |
| 429 | rate_limit_error | Too many requests, or your devices with the model are busy. |
| 502 | device_error | The device could not answer. |
| 503 | device_error | No device can take the request: none is set up, they are offline, or none picked it up in time. |
| 504 | timeout_error | The request took too long, or the device stopped responding while answering. |
Limits
| Request body | 256 KiB |
|---|---|
| Requests per API key | 60 per minute |
| Requests per account | 120 per minute, app and API together |
| Requests running at once | 4 per account, app and API together |
| Time per request | 280 seconds |
| Waiting for a device | 30 seconds |
| Reply length | 8,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 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"}]
}'
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="")
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 ?? "");
}