dotAI
OpenAI-Compatible Inference API
The dotAI feature exposes a second REST API family, at /api/inference/v1, that speaks the OpenAI chat-completions wire format instead of dotCMS's native request/response shapes. Point any OpenAI-compatible client, AI SDK, or agent framework at your dotCMS instance as its model provider — the base URL plus a dotCMS API token is the entire integration, with no dotCMS-specific client required.
This family works with the Vercel AI SDK, LangChain, LlamaIndex, the official OpenAI SDKs, and any other client built against the OpenAI chat-completions standard.
It sits alongside, and does not replace, the native dotAI REST API Resources at /api/v1/ai/*. Those endpoints remain fully functional; text/generate, image/generate, and completions/rawPrompt are superseded for most use cases by this family but are not removed. Endpoints with no standard OpenAI equivalent — RAG completions, semantic search, and the embeddings-index management endpoints — remain exclusive to /api/v1/ai/*.
Prerequisites#
This API uses the same underlying dotAI configuration as the rest of the feature — configure your provider(s) under Settings > Apps > dotAI before calling these endpoints. There is nothing additional to install or enable.
Authentication#
Every call must carry a dotCMS API token as a bearer token:
Authorization: Bearer <your-dotcms-api-token>This family accepts bearer tokens only — a session cookie or Basic authentication header is rejected. The token's owner can be a backend or frontend user; anonymous calls are rejected.
A dotCMS API token carries its owner's full authority for as long as it is valid. Treat it the same way you would any other long-lived credential: never place it in client-side/browser JavaScript, and scope the token's owning user to the minimum role your integration needs.
Model access for non-admin tokens. The OpenAI wire format lets the caller name any model string in the request. If the token's owner is not an administrator, the requested model is validated against the models actually configured for the resolved site (via chat, embeddings, or image provider configuration, including fallback chains) rather than passed through to the provider unchecked. Use GET /models to discover exactly which model ids are available before calling.
Site Resolution#
Because the Host HTTP header is required by HTTP/1.1, pointing a client's baseURL at https://your-site.com/api/inference/v1 is already enough for dotCMS to resolve the correct site's dotAI configuration — no extra header or parameter is needed for the common case.
Resolution on this family is strict: if the resolved site has no dotAI configuration, the call fails with an OpenAI-shaped error rather than silently falling back to another site's credentials (this is a deliberate difference from some of the older /api/v1/ai/* behavior).
To target a specific site explicitly — useful when calling from a server, a container, or behind a proxy where the Host header does not match a known site alias — supply an override:
| Method | How |
|---|---|
| HTTP header | X-dotCMS-Site: <site id or hostname> |
| Query parameter | ?siteId=<site id or hostname> |
A header-based override is supported because most AI SDKs let you set custom headers (for example, the Vercel AI SDK's headers option) but do not support arbitrary extra query parameters alongside the standard chat-completions paths.
Every response — including error responses — carries an X-dotCMS-Resolved-Site header identifying which site actually served the request, so you can always confirm which site's credentials and model configuration were used.
Endpoints#
| Path | Method | Description |
|---|---|---|
/api/inference/v1/chat/completions | POST | Chat completions with tool calling, multi-turn messages[], and SSE streaming |
/api/inference/v1/embeddings | POST | Returns an embedding vector for input text |
/api/inference/v1/models | GET | Lists the models configured for the resolved site, across chat, embeddings, and image generation |
/api/inference/v1/images/generations | POST | Generates an image in the OpenAI response shape |
The legacy OpenAI non-chat /completions endpoint is intentionally not implemented here — it is deprecated upstream and not part of this family.
Chat Completions#
Endpoint: POST /api/inference/v1/chat/completions
Accepts an OpenAI-shaped request body with a messages[] array using system, user, assistant, and tool roles, and a required model. Tool calling round-trips in full: send tools[] in the request, receive tool_calls in the response, and send the corresponding role: "tool" result messages on the next turn.
Required:
| Field | Description |
|---|---|
model | Must exactly match one of the models configured for the resolved site (see GET /models). There is no default model and no alias — a model that is not currently configured, including one a previous session used before a provider was swapped, returns a 404. |
messages | Array of turns. A turn's content may be a plain string, or an array of parts for multi-part text. Only text parts are supported — image/vision parts are refused with a 400 naming the unsupported part type. |
Example request:
{
"model": "gpt-4o",
"messages": [
{ "role": "system", "content": "You are a helpful assistant." },
{ "role": "user", "content": "Summarize this page's accessibility issues." }
],
"temperature": 0.3,
"stream": false
}Example response:
{
"id": "chatcmpl-CZJuecFUiWcPKTk9MYqJ6Qu5mBTpI",
"object": "chat.completion",
"created": 1762534060,
"model": "gpt-4o",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Here's a summary of the issues found...",
"refusal": null
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 42,
"completion_tokens": 58,
"total_tokens": 100
}
}Streaming. Set "stream": true to receive spec-conformant chat.completion.chunk events as text/event-stream, each including id, object, created, model, and (on the final chunk) finish_reason. The stream is terminated with a [DONE] event. When the model emits tool calls, their arguments stream incrementally across chunks the same way OpenAI's own streaming tool-call deltas do.
Ignored parameters. frequency_penalty, presence_penalty, seed, and user are accepted for client compatibility but are not sent to the underlying provider — only temperature, max_tokens, top_p, and stop are forwarded. Because seed is ignored, responses are not reproducible across calls.
Embeddings#
Endpoint: POST /api/inference/v1/embeddings
Returns a vector embedding for the supplied input text, in the standard OpenAI embeddings response shape. model is required and must match one of the embedding models configured for the site.
{
"model": "text-embedding-ada-002",
"input": "Run your entire digital ecosystem securely and visually."
}List Models#
Endpoint: GET /api/inference/v1/models
Lists every model currently configured for the resolved site, across chat, embeddings, and image generation, including any fallback chain entries. Use this before naming a model in any other call on this family — the embeddings and images endpoints require an exact, correct model id and have no other discovery path.
The response follows the standard OpenAI model-list shape (one object per model, with no dotCMS-specific capability field added to it) — if you call an operation with a model that doesn't support it, that operation's own validation refuses the request and names the mismatch.
Image Generation#
Endpoint: POST /api/inference/v1/images/generations
Generates an image from a prompt, in the OpenAI response shape.
{
"model": "dall-e-3",
"prompt": "A serene mountain landscape with a lake"
}The request does not send an explicit response_format — different image models have different (and non-overlapping) rules about it, so the endpoint lets each model return its own natural default (typically a URL for older DALL-E-style models, base64 for newer GPT image models) rather than forcing one shape that only some models accept.
Error Handling#
Errors are returned in an OpenAI-shaped error body. The HTTP status code is the signal a client should use to decide whether to retry:
- 400 — the request is permanently unresolvable as sent: a malformed request, an unconfigured site, an unrecognized or unauthorized model, an exhausted provider account, or a provider that flatly does not support what was asked (for example, an image part in a chat message). Retrying the same request will not help; for a provider-account problem (such as insufficient credit), the fix is on the provider-account side, not the request.
- 5xx — a transient failure on the provider's side. These are safe for a well-behaved client to retry with backoff.
Provider-originated error text is sanitized before it reaches you — internal details such as endpoint URLs, API keys, or prompt fragments from a failed provider call are not echoed back in the error response; they are logged server-side instead.
Rate Limiting and CORS#
These endpoints are covered by the same request-cost/rate-limiting mechanism used across dotCMS (off by default, and a general request-rate safeguard rather than a per-site AI spending budget). A capacity limit here is not a substitute for monitoring your own provider usage and costs.
CORS is not enabled for this family, deliberately. Because the credential is a long-lived dotCMS API token with its owner's full authority, enabling cross-origin access would make it far too easy to end up shipping that token inside browser JavaScript. Call these endpoints from your own server or server-side route handler, the same way every AI SDK application already calls its model provider.
Known Limitations#
- No vision support. Only text content is accepted in
messages[]; an image or other non-text content part is refused with a 400 naming the part type, rather than being silently dropped. - Several OpenAI sampling parameters are accepted but ignored:
frequency_penalty,presence_penalty,seed,user. Onlytemperature,max_tokens,top_p, andstopreach the underlying provider. - No default model or alias.
modelis required on every chat, embeddings, and image call. If a provider is swapped for a site, a client still requesting the old model id receives a 404 and must re-readGET /models. - A provider's
Retry-Afterheader is not relayed to the caller on a 5xx. dotCMS's own capacity-related refusals do includeRetry-After; an upstream provider's ownRetry-Aftercurrently is not forwarded.
Example: Connecting an AI SDK#
Using the Vercel AI SDK's OpenAI-compatible provider:
import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
const dotcms = createOpenAICompatible({
name: 'dotcms',
baseURL: 'https://your-dotcms-instance.com/api/inference/v1',
apiKey: process.env.DOTCMS_API_TOKEN,
});
const model = dotcms('gpt-4o');Any client built against the standard works the same way: set baseURL to https://<your-host>/api/inference/v1 and apiKey to a dotCMS API token.