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;
}