Private Inference API
The Private Inference API gives you the platform's self-hosted models directly, in the request and response shape of the OpenAI chat-completions API. An OpenAI-compatible client works by changing its base URL.
| Base URL | https://changents.ai/api/v1, or https://<your-host>/api/v1 on your own installation |
|---|
| Endpoint | What it does |
|---|---|
GET /api/v1/models | The models this installation serves, and the data class each is approved for |
POST /api/v1/chat/completions | A chat completion; stream: true for server-sent events |
POST /api/v1/embeddings | Embeddings from a self-hosted embedding model |
What makes it private
- Self-hosted models only. Requests go to the platform's own model host. If your organisation restricts where data is processed, that restriction applies here too. This API never sends a prompt to a hosted model provider.
- Nothing kept. Prompts and completions are neither stored nor logged. The only record is a token-usage row (model, token counts, duration) for billing. Every response carries
X-Retention-Applied: none. See No-Retention Mode. - Governed models. A model must be registered, not blocked, and approved for the data you send. Declare that with
X-Data-Classification: PUBLIC | SENSITIVE | RESTRICTED(defaultSENSITIVE). A model approved only toSENSITIVErefuses aRESTRICTEDrequest with403.
Keys
Use a key with the inference scope. On /developer, choose Create Inference Key, or call:
curl -X POST https://changents.ai/api/developer/keys \
-H "Authorization: Bearer <session token>" -H "Content-Type: application/json" \
-d '{ "name": "inference", "scopes": ["inference"] }'The scope is never granted by default. A key made for running agents cannot call models directly, and an inference key cannot run agents. Session tokens are not accepted on this API.
Example
curl https://changents.ai/api/v1/chat/completions \
-H "Authorization: Bearer cgnt_sk_<clientId>.<secret>" \
-H "X-Data-Classification: SENSITIVE" \
-H "Content-Type: application/json" \
-d '{ "model": "gemma2:2b",
"messages": [{ "role": "user", "content": "Summarise these payment terms: …" }] }'from openai import OpenAI
client = OpenAI(base_url="https://changents.ai/api/v1", api_key="cgnt_sk_<clientId>.<secret>")
reply = client.chat.completions.create(
model="gemma2:2b",
messages=[{"role": "user", "content": "Summarise these payment terms: …"}],
)Accepted fields: model, messages (roles system, user, assistant; 1–200 messages), temperature, top_p, max_tokens, stop, seed, response_format, frequency_penalty, presence_penalty, stream. Others are ignored. max_tokens is capped at the installation's limit (INFERENCE_MAX_TOKENS, default 2048). With stream: true, the last event before [DONE] carries usage.
Errors
Errors use the OpenAI error shape: {"error": {"message", "type", "code"}}.
| Status | Code | Meaning |
|---|---|---|
| 401 | invalid_api_key | No key, or an unknown or revoked key |
| 403 | insufficient_scope | The key lacks the inference scope |
| 403 | classification_not_permitted | The model is not approved for the declared data class |
| 404 | model_not_found | Not a model this API serves; see GET /api/v1/models |
| 402 | insufficient_credit | No credit left; checked before the model is called |
| 429 | rate_limit_exceeded | Over the per-key limit (INFERENCE_RATE_PER_MIN, default 60) |
| 502 | host_unavailable, host_error | The model host did not answer or refused the request |
Billing
On the hosted service, each call costs INFERENCE_CREDITS_PER_1K_TOKENS credits per thousand tokens (default 1), rounded up. The credits come from your organisation's pool first, then your own wallet. On your own installation, usage runs under your licence and is not charged.
Which models
GET /api/v1/models lists the registered self-hosted models that the model host has actually loaded. On the hosted service today that is a small CPU-served model, and answers are slower and less capable than a hosted frontier model. Larger models need a GPU host; see Models & GPU.