Skip to main content

Documentation Index

Fetch the complete documentation index at: https://aimp.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

JavaScript examples

Use API keys only in server-side JavaScript. Browser apps should rely on the signed-in product session and short-lived access tokens.

Node.js server

const gatewayUrl = process.env.AIMP_GATEWAY_URL.replace(/\/$/, "");

export async function runModel(text) {
  const response = await fetch(`${gatewayUrl}/api/runs`, {
    method: "POST",
    headers: {
      "X-API-Key": process.env.AIMP_API_KEY,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      model: "demo-model",
      mode: "execute",
      scope: "playground",
      input: { text },
      params: {},
    }),
  });

  const body = await response.json();
  if (!response.ok) {
    throw new Error(body?.error?.message || body?.detail || "AIMP request failed");
  }
  return body;
}

Signed-in browser flow

When you are inside the product app, call the same-origin API proxy and use the access token managed by the app:
await fetch("/api/runs", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${accessToken}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "demo-model",
    mode: "execute",
    scope: "playground",
    input: { text: "Hello" },
    params: {},
  }),
});
Do not embed AIMP_API_KEY in browser JavaScript.