Appbricx
Docs
FeaturesPricingStart free

Get started

OverviewWhat Appbricx isQuickstart with a coding agentQuickstart with the builderCore concepts

Guides

Data and tablesAccess and rolesBusiness rulesSign-inCustom screensRealtime and topicsWorkflows, schedules and webhooksServer functionsAI in your appPaymentsFilesMessagesIntegrationsVerifyPublishing, domains and rollbackOperating your appExport and self-hostSelf-host install

Tutorials

Build a booking app with Claude CodeMulti-user todo listClient portalSlack on new sign-upTemplates

Reference

Reference homeFrontend SDKHTTP APIMCP toolsCLIIntegrations catalogContract formatAI key resolutionRun Appbricx locally

AI API

Chat completions and embeddings with the project's own key or plan credits, metered per app and per user.

2 endpointsHTTP API referenceGuide: Add AI to your app

On this page
  1. Authentication
  2. Endpoints
  3. POST /ai/chat
  4. POST /ai/embed

Base URL: your app's origin ($APP_ORIGIN): the published host, a custom domain, or the platform origin for the builder preview. Errors answer { ok: false, error: { code, message } } unless noted. Add x-appbricx-env: dev or prod to pick the database explicitly; otherwise the host decides (preview means dev, a published host means prod).

Authentication

App key
A project key or preview token identifies the app. No user session is needed. Authorization: Bearer $APP_KEY

Endpoints

Chat completion

POST/__appbricx/ai/chat

One chat completion with the project's resolved model. Streams server-sent events by default; send stream: false for one JSON answer. The project's system prompt is prepended.

Auth
App key: Authorization: Bearer $APP_KEY

Body

NameTypeDescription
messagesrequiredArray<{ role, content }>1 to 64 messages; role is system, user or assistant.
streamoptionalbooleanDefault true (SSE). false answers JSON.
max_tokensoptionalnumberUpper bound on the answer (the project cap applies).

Response

Streaming: data: {"type":"text_delta","data":"…"} events, then {"type":"done","data":{ usage }} and [DONE].

Response
{
  "ok": true,
  "content": "The floor 3 printer jams when printing on A3.",
  "usage": {
    "prompt_tokens": 21,
    "completion_tokens": 11
  },
  "elapsed_ms": 840
}

Errors

StatusCodeWhen
401UNAUTHORIZEDMissing or invalid Authorization bearer ("Missing Authorization: Bearer <token>", "Invalid API key").
429RATE_LIMITEDThe project's per-minute request budget is spent (600 for preview tokens and browser keys, 1200 for server keys by default).
403TOOL_NOT_ALLOWEDThe key may not call ai.chat.
400PARAMS_INVALIDmessages missing, too many, or malformed.
413PAYLOAD_TOO_LARGEBody over 1 MB.
400INPUT_TOO_LARGEPrompt over the project's input cap.
402BUDGET_EXCEEDEDPer-user or project token budget spent.
402INSUFFICIENT_CREDITSPlan credits used up (platform-funded key).
403MODEL_NOT_ALLOWEDThe model isn't on the project's allow-list.
503AI_DISABLED_FOR_PROJECTAI is off for this project.
503PROVIDER_ERRORThe provider failed.
curl
curl -X POST "$APP_ORIGIN/__appbricx/ai/chat" \
  -H "Authorization: Bearer $APP_KEY" \
  -H "content-type: application/json" \
  -d '{"messages":[{"role":"user","content":"Summarize: the printer on floor 3 jams on A3 paper."}],"stream":false,"max_tokens":120}'
fetch
const res = await fetch(`${APP_ORIGIN}/__appbricx/ai/chat`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${APP_KEY}`,
    "content-type": "application/json",
  },
  body: JSON.stringify({
    "messages": [
      {
        "role": "user",
        "content": "Summarize: the printer on floor 3 jams on A3 paper."
      }
    ],
    "stream": false,
    "max_tokens": 120
  }),
});
const data = await res.json();
if (!res.ok) throw new Error(data.error?.message ?? data.error ?? res.statusText);

Relatedapp.ai.askapp.ai.chat

Source: services/api/src/routes/ai-proxy.ts:833

Embeddings

POST/__appbricx/ai/embed

Embedding vectors for a batch of texts with the configured embedding provider.

Auth
App key: Authorization: Bearer $APP_KEY

Body

NameTypeDescription
textsrequiredstring[]1 to 100 texts, each up to 8192 characters.

Response

Response
{
  "ok": true,
  "vectors": [
    [
      0.012,
      -0.034,
      "…"
    ],
    [
      0.021,
      0.004,
      "…"
    ]
  ],
  "model": "text-embedding-3-small",
  "dimensions": 1536,
  "elapsed_ms": 210
}

Errors

StatusCodeWhen
401UNAUTHORIZEDMissing or invalid Authorization bearer ("Missing Authorization: Bearer <token>", "Invalid API key").
429RATE_LIMITEDThe project's per-minute request budget is spent (600 for preview tokens and browser keys, 1200 for server keys by default).
403TOOL_NOT_ALLOWEDThe key may not call ai.embed.
400PARAMS_INVALIDtexts missing, too many or too long.
402BUDGET_EXCEEDEDBudget spent.
503AI_DISABLED_FOR_PROJECTAI is off.
503EMBEDDING_NOT_CONFIGUREDNo embedding provider.
503PROVIDER_ERRORThe provider failed.
curl
curl -X POST "$APP_ORIGIN/__appbricx/ai/embed" \
  -H "Authorization: Bearer $APP_KEY" \
  -H "content-type: application/json" \
  -d '{"texts":["printer jams on A3","projector won't turn on"]}'
fetch
const res = await fetch(`${APP_ORIGIN}/__appbricx/ai/embed`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${APP_KEY}`,
    "content-type": "application/json",
  },
  body: JSON.stringify({
    "texts": [
      "printer jams on A3",
      "projector won't turn on"
    ]
  }),
});
const data = await res.json();
if (!res.ok) throw new Error(data.error?.message ?? data.error ?? res.statusText);

Source: services/api/src/routes/ai-proxy.ts:1091

On this page

  1. Authentication
  2. Endpoints
  3. POST /ai/chat
  4. POST /ai/embed
Appbricx

The backend, runtime and hosting for apps your coding agent builds. On our cloud, in yours, or on your own servers.

Features

Coding agents and MCPVerify testingBuilder consolePostgres databaseData APIRealtimeRow-level securitySign-in and authPaymentsWorkflows and jobsAI in your appIntegrationsBackups and rollbackHosting and domainsSelf-host and exportAll features

Product

ShowcasePricingFor coding agentsTemplatesPrivate cloudBring your own AI keyFAQ

Compare

Appbricx vs SupabaseLovable alternativeBolt alternativeFor freelancersFor agencies

Resources

DocumentationReferenceBlogSupportContact

© 2026 Appbricx. All rights reserved.

TermsPrivacyCookiesAcceptable Use