PlatformXeDocs
Get API Key

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-room and knowledge search. The provider and model behind a profile — Gemini, Grok or Claude today — are profile settings Caldera changes without a client change. messages is 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.
EndpointPurposeScopeRate tier
POST /api/v1/ai/completeOne chat turn (Gemini, Grok or Claude)ai:complete600/hr per key
POST /api/v1/ai/extractPrompts (and images) in, schema-validated JSON outai:complete600/hr per key
POST /api/v1/ai/messagesOne native Claude Messages request (Claude 5.5 models)ai:complete600/hr per key
GET /api/v1/ai/toolsThe platform tools your key may use with toolsetstools:platform.read1,000/hr per key
GET /api/v1/ai/profile?featureKey=Your profile for one feature + today's usageai:complete600/hr per key
GET /api/v1/ai/usage?from=&to=&featureKey=Your AI and vision usageai:complete600/hr per key
POST /api/v1/vision/analyze-roomProperty photo → room category + alt textvision:analyze2,000/hr per key
PUT / DELETE / GET /api/v1/ai/knowledge/documentsIndex, delete and list your knowledge documentsai:knowledge1,200/hr per key
POST /api/v1/ai/knowledge/searchHybrid search over your documents, with citationsai:knowledge1,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:

SettingEffect
statusACTIVE or DISABLED. A disabled profile refuses with 403 AI_PROFILE_DISABLED; no profile at all is 403 AI_PROFILE_NOT_FOUND.
allowedProviders / allowedModelsWhich providers and models the feature may use (empty models list = the provider defaults).
Policy textAppended after the PlatformXe baseline policy. You own your prompts; PlatformXe owns the policy. Withheld from the profile view.
maxTokens, maxMessages, maxTotalCharsPer-call limits (see below).
allowImagesWhether extract accepts images.
allowToolsWhether complete accepts tools and tool-calling turns (see Tool calling).
dailyTokenCap, dailyRequestCapDaily caps per UTC day; null = no cap.
Output screening, PII redactionScreen 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).
maxEffortThe highest reasoning effort a Claude 5.5 call may use; a request's effort is capped by it.
allowCaching, allowStructuredOutputPrompt caching; outputSchema on messages.
fallbackModelThe model a declined Opus 5.5 request falls back to (claude-opus-5 or claude-opus-4-8); null = the default routing.
toolsets, maxToolTurns, allowedDataClassesWhich 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.
endUserFacingA 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.
strictIdRedactionAlso 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

LimitValue
Messages per complete turnThe 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 prompt32,000 characters
Images per extract4, each a public https url or base64 (≤ 8 MiB decoded, image/jpeg / image/png / image/webp) — only when the profile allows images
analyze-room imageExactly one of imageUrl (public https) / imageBase64 (≤ 8 MiB decoded)
Output tokensThe profile's maxTokens, never more than the deployment ceiling (256–32,768)
extract temperature0–2, default 0.2
Usage windowfrom / 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 whose toolsets lists the toolset and which is not end-user facing. Otherwise 403 AI_TOOLSET_DENIED. GET /api/v1/ai/tools lists the tools your key may use, with their input schemas and data classes.
  • Limits — at most maxToolTurns model turns and a cap on tool calls, within 120 s (422 AI_LOOP_LIMIT, details.reason TURNS / CALLS / DEADLINE). A tool that fails, times out or is denied goes back to the model as an error result; 502 AI_TOOL_FAILED means the tool round trip itself broke, and stops the request. With toolsets, toolChoice must be auto or 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, or messages), 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 as actor on /ai/messages who 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 /documents with featureKey, collection, your sourceRef, title, optional url and acl, and markdown or plain text (≤ 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, a collection + sourceRef is 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 a collection + sourceRef already held by another organisation under the same caller service is refused with 409 CONFLICT (use a different sourceRef). After that migration neither applies: each organisation holds its own document for the same collection + 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 — acl holds opaque tags you own. A search sees a document when its aclTags hold any of the document's tags; a document without tags is visible to every search of your service.
  • Search — POST /search with featureKey, collections, query (≤ 1,000 characters), aclTags and k (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"), otherwise mode: "lexical". Every hit carries sourceRef, ordinal and heading for a citation. The query is screened like any AI input.
  • Embeddings — Google text-embedding-005 through 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 their contentHash, ordered by sourceRef; page with the opaque nextCursor (it names the last document listed, so two documents sharing a sourceRef are both listed); delete what no longer exists on your side with DELETE /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):

SituationResponse
First request with a keyProcessed; the response is stored for 24 h
Same key again, after it finishedThe stored response, with X-Idempotency-Cache: HIT
Same key while the first is still running409 CONFLICT
The answer was a FALLBACKReturned with X-Idempotency-Cache: skip and not stored — retrying the same key later reaches the provider again
The idempotency store is unavailable503 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"? } }.

CodeStatusEndpointsMeaning
BAD_REQUEST400allMalformed body or query, or a limit breached
UNAUTHORIZED401allMissing, invalid or inactive API key
FORBIDDEN403allThe key lacks ai:complete / ai:knowledge / vision:analyze / tools:platform.read, or its organization is inactive
AI_TOOLSET_DENIED403complete, messagesNo 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_FOUND403complete, extract, profile, analyze-room, knowledge PUT + searchNo profile for your caller service + featureKey: neither your organisation's nor the platform one
AI_PROFILE_DISABLED403complete, extract, analyze-room, knowledge PUT + searchThe profile is switched off
AI_POLICY_DENIED403complete, extract, knowledge searchThe input was refused by the safety screen
CONFLICT409analyze-room, knowledge PUTanalyze-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_BLOCKED422complete, extractThe model reply was refused by output screening
AI_OUTPUT_INVALID422extractThe reply did not match outputJsonSchema; details.path is the JSON Pointer of the first failing value
AI_REFUSED422complete, extract, messagesThe model declined and no fallback answered; no content, the call is billed; details.category
AI_LOOP_LIMIT422complete, messagesThe tool loop hit its turn or call cap or its time budget; details.reason
RATE_LIMITED429allThe per-key rate tier is spent (Retry-After)
AI_QUOTA_EXCEEDED429complete, extract, analyze-roomThe profile's daily cap is reached (Retry-After to the next UTC midnight; details.metric)
AI_BUDGET_EXCEEDED429complete, extract, messages, analyze-roomA 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_ERROR500allUnexpected failure
AI_UPSTREAM_ERROR502complete, extract, messagesThe model provider failed or timed out
AI_TOOL_FAILED502complete, messagesThe server-side tool round trip itself broke; the request was stopped
AI_NOT_CONFIGURED503complete, extract, messagesThe 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_UNAVAILABLE503complete, extractThe 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_CONFIGURED503analyze-roomNo vision provider (AI gateway or Azure fallback) is configured on that deployment
IDEMPOTENCY_UNAVAILABLE503analyze-roomThe 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.