API
Chat completions
An OpenAI-compatible API: change one base URL and keep your code.
PRINET exposes an OpenAI-compatible chat completions API with no logging, billed per token. Existing OpenAI clients work by changing the base URL and API key.
Endpoint
HTTP
POST /v1/chat/completionsRequest body
| Field | Type | Notes |
|---|---|---|
model | string | A model the network serves. List them with GET /v1/models. |
messages | array | 1–100 messages, each with a role (system, user, assistant) and text content. |
stream | boolean | Stream tokens as server-sent events. Defaults to true. |
temperature | number | 0 to 2. |
max_tokens | integer | 1 to 8192. |
Examples
curl
curl $PRINET_API_BASE/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $PRINET_API_KEY" \
-d '{
"model": "MODEL_ID",
"messages": [{ "role": "user", "content": "Hello" }],
"stream": true
}'JavaScript (openai)
import OpenAI from "openai";
const client = new OpenAI({
baseURL: process.env.PRINET_API_BASE,
apiKey: process.env.PRINET_API_KEY,
});
const res = await client.chat.completions.create({
model: "MODEL_ID",
messages: [{ role: "user", content: "Hello" }],
});
console.log(res.choices[0].message.content);Python (openai)
from openai import OpenAI
import os
client = OpenAI(
base_url=os.environ["PRINET_API_BASE"],
api_key=os.environ["PRINET_API_KEY"],
)
res = client.chat.completions.create(
model="MODEL_ID",
messages=[{"role": "user", "content": "Hello"}],
)
print(res.choices[0].message.content)Listing models
HTTP
GET /v1/modelsBilling
Requests are billed per token in $PRINET. Failed jobs are not charged. See Token and payments.