Product AI & Vision
How the PlatformXe AI & Vision gateway works — AI profiles, feature keys, limits, daily quotas and spend budgets, tool calling, native Claude messages, server-side platform tools, knowledge retrieval, error codes and idempotency.
PlatformXe runs your product's AI traffic through one gateway, so policy, limits and spend are controlled in one place. Your app sends prompts; PlatformXe decides what each feature may do.
Scope
PlatformXe is an infrastructure API. The AI & Vision gateway is one more capability on the same API as messaging, storage and OCR, and it is deliberately narrow:
- Your app owns the prompt, the context and the decision. PlatformXe never decides for the caller, never executes your tool calls (it returns them; your code runs them) and never acts on a result. The one exception is opt-in and read-only: with
toolsets, PlatformXe runs its own read-only platform tools over your own organisation's operational data in a bounded loop (see Server-side tools); it never writes. - One provider-neutral contract:
complete,extract,analyze-roomand knowledge search. The provider and model behind a profile — Gemini, Grok or Claude today — are profile settings Caldera changes without a client change.messagesis the one provider-shaped route: the Anthropic Messages shape, for apps already written against it. - Zero data retention on every request: the provider keeps neither prompt nor output; PlatformXe keeps a usage row (tokens, cost, feature) and a short-lived audit detail that the retention job purges.
- Metered in naira: the gateway's cost for every call is recorded against your feature; each profile's daily caps, and the spend budgets of your organisation, stop a runaway feature.
- Out of scope: training or hosting models, autonomous agents, and decisions taken on your behalf. PlatformXe routes, meters and polices your calls; it is not an AI product.
| Endpoint | Purpose | Scope | Rate tier |
|---|---|---|---|
POST /api/v1/ai/complete | One chat turn (Gemini, Grok or Claude) | ai:complete | 600/hr per key |
POST /api/v1/ai/extract | Prompts (and images) in, schema-validated JSON out | ai:complete | 600/hr per key |
POST /api/v1/ai/messages | One native Claude Messages request (Claude 5.5 models) | ai:complete | 600/hr per key |
GET /api/v1/ai/tools | The platform tools your key may use with toolsets | tools:platform.read | 1,000/hr per key |
GET /api/v1/ai/profile?featureKey= | Your profile for one feature + today's usage | ai:complete | 600/hr per key |
GET /api/v1/ai/usage?from=&to=&featureKey= | Your AI and vision usage | ai:complete | 600/hr per key |
POST /api/v1/vision/analyze-room | Property photo → room category + alt text | vision:analyze | 2,000/hr per key |
PUT / DELETE / GET /api/v1/ai/knowledge/documents | Index, delete and list your knowledge documents | ai:knowledge | 1,200/hr per key |
POST /api/v1/ai/knowledge/search | Hybrid search over your documents, with citations | ai:knowledge | 1,200/hr per key |
SDK reference: /sdk/ai and /sdk/vision. Machine-readable contract: the AI, AI Knowledge and Vision tags of the OpenAPI document.
AI profiles
Every call runs under an AI profile, selected by two values:
- the caller service — taken from your API key, never from the request body, so one app cannot borrow another app's profile;
featureKey— names the product use case (guest-concierge,room-vision,ai-canvas,document.freeform…).
The profile is read for a caller service within the key's organisation: your organisation's own profile for the feature, set up by Caldera. Another organisation's profile is never used, even under the same caller service name. Since 2026-11-17 a key with an organisation no longer falls back to a platform profile (one with no organisation) by caller service name: ask Caldera to set up your organisation's own profile (only Caldera's own applications use the platform profiles). A platform key (no organisation) uses the platform profile.
A profile is set up by Caldera for your service. It holds:
| Setting | Effect |
|---|---|
status | ACTIVE or DISABLED. A disabled profile refuses with 403 AI_PROFILE_DISABLED; no profile at all is 403 AI_PROFILE_NOT_FOUND. |
allowedProviders / allowedModels | Which providers and models the feature may use (empty models list = the provider defaults). |
| Policy text | Appended after the PlatformXe baseline policy. You own your prompts; PlatformXe owns the policy. Withheld from the profile view. |
maxTokens, maxMessages, maxTotalChars | Per-call limits (see below). |
allowImages | Whether extract accepts images. |
allowTools | Whether complete accepts tools and tool-calling turns (see Tool calling). |
dailyTokenCap, dailyRequestCap | Daily caps per UTC day; null = no cap. |
| Output screening, PII redaction | Screen model replies before returning them; redact emails, phone numbers, ID numbers, card numbers and labelled bank account numbers in your input before they reach the model (server-side tool results are always redacted, whatever this says). |
maxEffort | The highest reasoning effort a Claude 5.5 call may use; a request's effort is capped by it. |
allowCaching, allowStructuredOutput | Prompt caching; outputSchema on messages. |
fallbackModel | The model a declined Opus 5.5 request falls back to (claude-opus-5 or claude-opus-4-8); null = the default routing. |
toolsets, maxToolTurns, allowedDataClasses | Which server-side toolsets the feature may use, how many model turns the tool loop may take (1–25), and which data classes a tool result may carry. |
endUserFacing | A profile your end users talk to: output screening on, a non-empty allowedModels with no Opus model in it (an empty list would allow every model), no fallbackModel, no platform tools. An Opus model is also refused at call time. |
strictIdRedaction | Also redact unlabelled 11-digit numbers (NIN / BVN) and unlabelled 10-digit numbers (bank account numbers) before the model. |
GET /api/v1/ai/profile?featureKey=… (client.ai.profile) shows your profile's settings with today's usedTokensToday, usedRequestsToday and resetsAt (the next UTC midnight).
Feature keys
A featureKey is 1–64 lowercase letters, digits, . or -, starting with a letter or digit. It is required on complete and extract; analyze-room defaults to room-vision.
sourceApp is a deprecated alias for featureKey (types 3.5.0; removed in 4.0.0). It is only read when featureKey is absent. Send featureKey.
Limits
| Limit | Value |
|---|---|
Messages per complete turn | The profile's maxMessages, never more than 64 |
Characters per turn (all message content, or both extract prompts together) | The profile's maxTotalChars, never more than 256,000 |
Each extract prompt | 32,000 characters |
Images per extract | 4, each a public https url or base64 (≤ 8 MiB decoded, image/jpeg / image/png / image/webp) — only when the profile allows images |
analyze-room image | Exactly one of imageUrl (public https) / imageBase64 (≤ 8 MiB decoded) |
| Output tokens | The profile's maxTokens, never more than the deployment ceiling (256–32,768) |
extract temperature | 0–2, default 0.2 |
| Usage window | from / to at most 92 days apart; default the last 30 days |
A breached limit is 400 BAD_REQUEST.
Daily quotas
A profile's dailyTokenCap and dailyRequestCap are counted per UTC day and per organisation: another organisation using the same profile (the platform one, say) never uses up your cap, and GET /api/v1/ai/profile's usedTokensToday / usedRequestsToday are your organisation's only. They are checked after the safety screen and before the model is called; a call that reaches the provider counts against them.
When a cap is reached the call is refused with 429 AI_QUOTA_EXCEEDED, a Retry-After header with the seconds until the next UTC midnight, and error.details = { metric, retryAfterSeconds }. It is distinct from the per-key rate tier (429 RATE_LIMITED, which resets within the hour). The official SDKs do not retry AI_QUOTA_EXCEEDED.
Spend budgets
Caldera can also set a spend budget (in naira, per UTC day or month) on your organisation or on one caller service. A hard budget that is spent refuses AI and vision calls before any provider is called, with 429 AI_BUDGET_EXCEEDED, Retry-After to the end of the period (60 s when the spend could not be read) and error.details = { period, retryAfterSeconds }. When a hard budget could not be checked, details.reason is BUDGET_UNAVAILABLE. A tool loop stopped by its budget between model calls answers error.details = { retryAfterSeconds: 60 } (no period) and is billed for the turns that ran. Requests running at the same time count each other's finished model turns, but a model call is counted only once it returns, so a hard budget can be passed by at most one model call per request running at that moment. A soft budget only alerts. A knowledge search is never refused by a budget: its query embedding is skipped and the search answers in lexical mode. The official SDKs do not retry AI_BUDGET_EXCEEDED.
Usage and cost
Every call that reached a profile is recorded once — succeeded (OK), refused by the safety screen (REFUSED), blocked on output (BLOCKED), over quota (QUOTA_EXCEEDED), degraded (FALLBACK, vision) or failed (FAILED). GET /api/v1/ai/usage (client.ai.usage) returns your own usage (a caller service within the key's organisation: your organisation's calls and the calls recorded with no organisation, never another organisation's, even under the same caller service name; a platform key sees the calls with no organisation) grouped by feature, kind (ai / vision / embedding / messages / complete_with_tools), provider and model, with token counts and cost in PlatformXe credits (1 credit = 1 kobo). Knowledge embeddings — at indexing time and for a search query — are recorded as kind embedding against the profile named by the request's featureKey.
Tool calling
With allowTools on the profile, POST /api/v1/ai/complete accepts tools (up to 16 function tools: name, description, JSON Schema parameters) and toolChoice (auto, none, required or { name }). The reply may carry toolCalls with finishReason: "tool_calls".
PlatformXe is a pipe for tools: it never executes a tool call. Your app runs each call through its own permission checks and audit, then sends the result back as a role: "tool" message (toolCallId) after the assistant message that carried the calls.
Tool traffic gets the same data handling as text: input screening and PII redaction cover tool results and earlier call arguments, output screening covers every returned call's arguments, and redaction placeholders are restored in the arguments you receive. Without allowTools, tools or tool messages are refused with 400 BAD_REQUEST ("tools not enabled for this feature").
Native Claude messages
POST /api/v1/ai/messages (scope ai:complete) takes the Anthropic Messages request shape on the Claude 5.5 models your profile allows, under the same governance as complete: allow-lists and limits, PII redaction before the model and restore after, input safety, daily caps and spend budgets before the call, output screening, one usage row (kind messages). featureKey is required (no sourceApp alias). The call always sends an effort (yours, capped by the profile's maxEffort); toolChoice is auto or none only (auto or left out with toolsets); outputSchema needs allowStructuredOutput and a schema that follows the structured-output rule: an object root, and every object node needs additionalProperties: false (required is optional). Accepted: pattern, minProperties / maxProperties, minItems 0 or 1, and format one of date-time, time, date, duration, email, hostname, uri, ipv4, ipv6, uuid. Refused with 400 naming the keyword: numeric bounds (minimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf), string lengths (minLength, maxLength), maxItems, uniqueItems, minContains / maxContains, minItems above 1, and any other format. The request limits also apply: at most 24 optional parameters and 16 union-type parameters (anyOf or a type array) across the schema and any strict tools. No streaming; one 120 s deadline.
A model refusal is 422 AI_REFUSED with details.category and no content; partial output is discarded and the call is billed. When the profile names a fallbackModel, a declined Opus 5.5 request is answered by that model instead, and the answer's model says which one answered. The reply's content then starts at the last fallback block (that block included); a fallback block's trigger sent back is at most 512 characters as JSON, and only its type and category (at most 64 characters, or null) are kept.
Server-side tools
toolsets on messages (or on complete with a Claude 5.5 model) turns on PlatformXe's read-only platform tools: the model can look up your webhooks and deliveries, the event log, messaging log metadata, issues and usage, of your own organisation only. PlatformXe runs each tool call itself, checks it in order (tenant, scope, toolset, data class, permission, budget) and records it, then hands the result to the model as data; tool output never carries message bodies, SMS or WhatsApp text, secrets or raw rows, and personal data in it is always redacted before the model sees it, whatever the profile's PII redaction setting. When the profile's PII redaction is off, the reply keeps the placeholders (‹EMAIL_1› and so on) that stand for a tool's personal data; a placeholder you send back in a later request stays a placeholder (it is never resolved again, and never given to another value). There are no write tools.
- Who may use them — an organisation key holding
tools:platform.read, on a profile whosetoolsetslists the toolset and which is not end-user facing. Otherwise403 AI_TOOLSET_DENIED.GET /api/v1/ai/toolslists the tools your key may use, with their input schemas and data classes. - Limits — at most
maxToolTurnsmodel turns and a cap on tool calls, within 120 s (422 AI_LOOP_LIMIT,details.reasonTURNS/CALLS/DEADLINE). A tool that fails, times out or is denied goes back to the model as an error result;502 AI_TOOL_FAILEDmeans the tool round trip itself broke, and stops the request. Withtoolsets,toolChoicemust beautoor left out (400). - What you get back —
toolRuns: one summary per tool call (name, version, status, deny reason, latency, output size); never the input or the output. - Metering — the whole loop is one usage row (kind
complete_with_tools, ormessages), every model turn included. - First-party app tools — Caldera's own apps can offer their own read-only tools to their own features (ErrandOne's desk tools first, toolset
concierge.desk-read). PlatformXe calls the app for each tool call, signed both ways, and the app checks the person and its own permissions every time. Such a tool runs only for that app's own key naming its scope (tools:concierge.read), and only for a person passed asactoron/ai/messageswho holds the tool's permission. Caldera's own operator console can use each app's read tools (Lettings, ErrandOne, Chats, xAdmin) for the person signed in, and only what that person may see in each app (actors, one entry per app). A tenant only ever sees its own tools; these tools are not on the remote MCP.
Remote MCP
The same platform tools are served over the Model Context Protocol at https://mcp.platformxe.com/mcp, for an MCP client you run: the Claude API MCP connector, Claude Managed Agents, or an IDE. Your client owns the prompt and the decision; PlatformXe answers the tool calls it is asked for with the same checks and the same record of every call, for the key's own organisation only, and never writes. It needs a dedicated key naming mcp:connect (with tools:platform.read), and a key used by Claude Managed Agents, which keeps session history, is served only tools that return no personal data. See Remote MCP.
Knowledge retrieval
/api/v1/ai/knowledge/* (scope ai:knowledge) indexes your own documents — policies, handbooks, knowledge pages — and searches them, so an assistant can answer from your data with citations.
- Indexing —
PUT /documentswithfeatureKey,collection, yoursourceRef,title, optionalurlandacl, and markdown or plaintext(≤ 400,000 characters). The text is split by heading into ~800-token chunks with a 100-token overlap; fenced code is never split. Re-sending the same text only updates the metadata. A document records your API key's organisation. Until the contract migration that keys documents by organisation alone, acollection+sourceRefis still unique per caller service, so two rules apply: a document indexed before documents recorded an organisation is recorded under yours the first time your key writes it, and acollection+sourceRefalready held by another organisation under the same caller service is refused with409 CONFLICT(use a differentsourceRef). After that migration neither applies: each organisation holds its own document for the samecollection+sourceRef. - Whose documents — list, delete and search reach the documents of a caller service within the key's organisation: your organisation's, and those indexed before documents recorded an organisation (until they are claimed or assigned). Another organisation's documents are never listed, deleted or searched, even under the same caller service name. A platform key reaches only documents with no organisation.
- ACLs —
aclholds opaque tags you own. A search sees a document when itsaclTagshold any of the document's tags; a document without tags is visible to every search of your service. - Search —
POST /searchwithfeatureKey,collections,query(≤ 1,000 characters),aclTagsandk(1–20, default 8). Candidates come from Postgres full-text and trigram (typo-tolerant) matching; when embeddings are available the query is embedded and cosine similarity is fused with the lexical ranks by reciprocal rank fusion (mode: "hybrid"), otherwisemode: "lexical". Every hit carriessourceRef,ordinalandheadingfor a citation. The query is screened like any AI input. - Embeddings — Google
text-embedding-005through the AI gateway with zero data retention. When the gateway is unavailable, documents are still indexed and searchable lexically; embeddings are filled in later. - Reconciliation —
GET /documents?collection=lists your documents with theircontentHash, ordered bysourceRef; page with the opaquenextCursor(it names the last document listed, so two documents sharing asourceRefare both listed); delete what no longer exists on your side withDELETE /documents?collection=&sourceRef=.
Indexed text is stored exactly as sent: PlatformXe does not redact personal data at index time. Do not index Tier-1 / Tier-2 personal data. Documents are kept until you delete them.
Vision
POST /api/v1/vision/analyze-room classifies a property photo into one of the roomCategories you send (your own taxonomy) and, when wantAltText is true, writes alt text in the requested locale (en-NG, en-GB or en-US). The response carries roomCategory (or null), roomConfidence, altText, detectedFeatures, modelVersion, aiStatus and metrics.
A provider timeout or overload is not an error: the endpoint answers 200 with aiStatus: "FALLBACK" and a deterministic answer, so an upload flow never blocks on it.
Idempotency
analyze-room accepts an optional x-idempotency-key header (scoped to your API key):
| Situation | Response |
|---|---|
| First request with a key | Processed; the response is stored for 24 h |
| Same key again, after it finished | The stored response, with X-Idempotency-Cache: HIT |
| Same key while the first is still running | 409 CONFLICT |
The answer was a FALLBACK | Returned with X-Idempotency-Cache: skip and not stored — retrying the same key later reaches the provider again |
| The idempotency store is unavailable | 503 IDEMPOTENCY_UNAVAILABLE with Retry-After — nothing ran, retry is safe |
Error responses (400, 401, 403, 404, 422, 429 and 5xx) are never stored.
Error codes
Every error uses the standard envelope { "success": false, "error": { "code", "message", "details"? } }.
| Code | Status | Endpoints | Meaning |
|---|---|---|---|
BAD_REQUEST | 400 | all | Malformed body or query, or a limit breached |
UNAUTHORIZED | 401 | all | Missing, invalid or inactive API key |
FORBIDDEN | 403 | all | The key lacks ai:complete / ai:knowledge / vision:analyze / tools:platform.read, or its organization is inactive |
AI_TOOLSET_DENIED | 403 | complete, messages | No tool of the requested toolsets can be offered; answered before any model call (nothing spent). details.reason: SOURCE_UNAVAILABLE (a first-party app's tools are switched off or not readable; a switch-off reaches every instance within 60 s), DATA_CLASS (refused by the profile's data classes) or NOT_ALLOWED (not on the profile, or the key or actor may use none of its tools). Fall back to a path without tools only on SOURCE_UNAVAILABLE. With several toolsets requested, the request runs (and is billed) when any one still has a usable tool |
AI_PROFILE_NOT_FOUND | 403 | complete, extract, profile, analyze-room, knowledge PUT + search | No profile for your caller service + featureKey: neither your organisation's nor the platform one |
AI_PROFILE_DISABLED | 403 | complete, extract, analyze-room, knowledge PUT + search | The profile is switched off |
AI_POLICY_DENIED | 403 | complete, extract, knowledge search | The input was refused by the safety screen |
CONFLICT | 409 | analyze-room, knowledge PUT | analyze-room: the idempotency key is still in flight. Knowledge PUT: the collection + sourceRef is held by another organisation under your caller service; use a different sourceRef (retrying does not fix it). Until the contract migration that keys documents by organisation alone |
AI_OUTPUT_BLOCKED | 422 | complete, extract | The model reply was refused by output screening |
AI_OUTPUT_INVALID | 422 | extract | The reply did not match outputJsonSchema; details.path is the JSON Pointer of the first failing value |
AI_REFUSED | 422 | complete, extract, messages | The model declined and no fallback answered; no content, the call is billed; details.category |
AI_LOOP_LIMIT | 422 | complete, messages | The tool loop hit its turn or call cap or its time budget; details.reason |
RATE_LIMITED | 429 | all | The per-key rate tier is spent (Retry-After) |
AI_QUOTA_EXCEEDED | 429 | complete, extract, analyze-room | The profile's daily cap is reached (Retry-After to the next UTC midnight; details.metric) |
AI_BUDGET_EXCEEDED | 429 | complete, extract, messages, analyze-room | A spend budget is spent (Retry-After to the period's end; details.period); details.reason BUDGET_UNAVAILABLE when it could not be checked; no period when the tool loop stopped between model calls |
SERVER_ERROR | 500 | all | Unexpected failure |
AI_UPSTREAM_ERROR | 502 | complete, extract, messages | The model provider failed or timed out |
AI_TOOL_FAILED | 502 | complete, messages | The server-side tool round trip itself broke; the request was stopped |
AI_NOT_CONFIGURED | 503 | complete, extract, messages | The AI gateway is not configured on that deployment (key missing or rejected), or, for a Claude 5.5 model, the native route is off |
AI_MODEL_UNAVAILABLE | 503 | complete, extract | The AI gateway account cannot use the requested model — paid gateway credits are required. The message is fixed ("The AI service account cannot use this model right now.") and details.model names the model; the gateway's own reason stays in Caldera's logs, and Caldera is alerted once per profile and model per day. Retrying does not fix it |
VISION_NOT_CONFIGURED | 503 | analyze-room | No vision provider (AI gateway or Azure fallback) is configured on that deployment |
IDEMPOTENCY_UNAVAILABLE | 503 | analyze-room | The idempotency store is unavailable — nothing ran |
/api/v1/ocr/* now requires its own scope, ocr:run. Keys created with the default scopes carry ai:complete, vision:analyze and ocr:run for the services that use them; an older key with an explicit scope list needs them granted before it can call these routes.