PACINFRAX · DEVELOPERS
Use the supported text contract deliberately.
Inspect gateway requests, project scopes and failure behavior.
Workflow overview
Permission before the request
Text support and terminal handling define the current subset.
Project scope
models:read or inference:write.
Text contract
Supported model and message fields.
Terminal handling
Check errors and truncated streams.
The implemented gateway is a local deterministic mock. The public API endpoint is not enabled.
Understand the text API subset.
OpenAI-style request shapes do not establish complete OpenAI compatibility. Use the detailed local contract for supported limits.
| Contract | Scope and behavior | Current boundary |
|---|---|---|
| GET /v1/models | Project key with models:read | Configured local gateway catalog |
| POST /v1/chat/completions | inference:write; text messages and supported parameters | Deterministic local mock |
| Server-sent events | Bounded stream; partial output and terminal validation | Transport contract, not GPU evidence |
| Tools, images and arbitrary parameters | Unsupported by the current text contract | Do not infer support from request similarity |
Public endpoint examples below are display-only. For an executable local setup, use the local gateway and test-key instructions in the documentation.
# Contract example; public endpoint is not enabled.
# Set PACINFRAX_API_KEY securely in your environment.
curl --no-buffer --fail-with-body --max-time 20 \
--proto '=https' --tlsv1.2 \
https://api.pacinfrax.ai/v1/chat/completions \
-H "Authorization: Bearer $PACINFRAX_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "<model-id>",
"messages": [{"role": "user", "content": "Hello"}],
"stream": true
}'
# Prints raw server-sent events, not parsed assistant text.# Python 3 stdlib; contract endpoint is not enabled.
import json
import os
import sys
import urllib.error
import urllib.request
class NoRedirect(urllib.request.HTTPRedirectHandler):
def redirect_request(self, req, fp, code, msg, headers, newurl):
return None
key = os.environ.get("PACINFRAX_API_KEY")
if not key:
raise SystemExit("Set PACINFRAX_API_KEY securely first.")
body = {
"model": "<model-id>",
"messages": [{"role": "user", "content": "Hello"}],
"stream": True,
}
request = urllib.request.Request(
"https://api.pacinfrax.ai/v1/chat/completions",
data=json.dumps(body).encode("utf-8"),
headers={"Authorization": "Bearer " + key,
"Content-Type": "application/json"},
method="POST",
)
try:
with urllib.request.build_opener(NoRedirect).open(request, timeout=20) as response:
if response.headers.get_content_type() != "text/event-stream":
raise SystemExit("Expected a streaming response.")
# Write raw SSE bytes; do not decode partial UTF-8 chunks.
while chunk := response.read1(4096):
sys.stdout.buffer.write(chunk)
sys.stdout.buffer.flush()
except urllib.error.HTTPError as error:
raise SystemExit("HTTP request rejected: " + str(error.code)) from None
except (urllib.error.URLError, OSError):
raise SystemExit("Streaming request failed.") from None// Node.js 20+ built-in fetch; contract endpoint is not enabled.
const key = process.env.PACINFRAX_API_KEY;
if (!key) throw new Error("Set PACINFRAX_API_KEY securely first.");
async function streamExample(): Promise<void> {
const response = await fetch(
"https://api.pacinfrax.ai/v1/chat/completions", {
method: "POST",
redirect: "error",
signal: AbortSignal.timeout(20_000),
headers: {
Authorization: "Bearer " + key,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "<model-id>",
messages: [{ role: "user", content: "Hello" }],
stream: true,
}),
},
);
if (!response.ok || !response.body ||
response.headers.get("content-type")?.split(";")[0].trim() !== "text/event-stream") {
await response.body?.cancel();
throw new Error("Expected a successful streaming response.");
}
const reader = response.body.getReader();
const decoder = new TextDecoder();
try {
// Print raw SSE frames, not parsed assistant text.
while (true) {
const { value, done } = await reader.read();
if (done) break;
process.stdout.write(decoder.decode(value, { stream: true }));
}
process.stdout.write(decoder.decode());
} finally {
await reader.cancel().catch(() => {});
reader.releaseLock();
}
}
streamExample().catch(() => {
console.error("Streaming request failed.");
process.exitCode = 1;
});Contract examples only: the public API endpoint is not enabled. Replace <model-id> with an authorized callable model ID before use. Examples print raw SSE events; they do not invoke a model on this page.
Review the decision requirements
Verify the API subset your backend integration requires.
- GET /v1/models requires models:read; POST /v1/chat/completions requires inference:write.
- Current chat messages contain text; tool calls, images, embeddings and batch submission are not part of this gateway contract.
- Read SSE through terminal usage and [DONE]. Truncated streams and timeouts must not trigger an automatic POST replay.
Open the detailed API reference