bruxel.ai

Ejemplos

El flujo de integración en curl, Python y JavaScript. Reemplaza bxk_tu_llave por la que creaste en la consola.

Autenticar y verificar

Toda llamada lleva tu API key como Bearer token. Empieza confirmando que funciona con GET /v1/me.

const BASE = "https://bruxel.ai/api/public/v1";
const h = { Authorization: "Bearer bxk_tu_llave" };

const res = await fetch(BASE + "/me", { headers: h });
console.log(await res.json()); // { tenant, key: { scopes, ... } }

Empujar tu catálogo

Sube o actualiza productos por SKU (upsert masivo, hasta 500 por request).

const res = await fetch(BASE + "/products", {
  method: "POST",
  headers: { ...h, "Content-Type": "application/json" },
  body: JSON.stringify({
    products: [{ sku: "CAMISA-001", name: "Camisa de lino", brand: "Acme" }],
  }),
});
console.log(await res.json()); // { total, created, updated, skipped }

Generar una descripción

Generación síncrona: cobra al éxito. El Idempotency-Key es recomendado para reintentos seguros.

const res = await fetch(BASE + "/generations", {
  method: "POST",
  headers: {
    ...h,
    "Content-Type": "application/json",
    "Idempotency-Key": "gen-camisa-001-v1",
  },
  body: JSON.stringify({ product_id: "prod_8f2", languages: ["es", "en"] }),
});
const data = await res.json(); // { results, total_credits_charged, balance }

Generar en lote

Para volumen: reserva créditos con Idempotency-Key obligatorio y haz poll hasta que el lote termine — el poll cobra los éxitos y reembolsa el resto.

const submit = await fetch(BASE + "/batches", {
  method: "POST",
  headers: {
    ...h,
    "Content-Type": "application/json",
    "Idempotency-Key": "batch-2026-07-23-a",
  },
  body: JSON.stringify({ product_ids: ["prod_8f2", "prod_9a1"] }),
});
const { id } = await submit.json();

// Poll hasta status "ended" (el GET cobra éxitos y reembolsa el resto)
let batch;
do {
  await new Promise((r) => setTimeout(r, 10000));
  batch = await (await fetch(BASE + "/batches/" + id, { headers: h })).json();
} while (batch.status !== "ended");

Leer y exportar

Lee la descripción actual de un producto o exporta todo el catálogo timbrado a CSV.

// Descripción actual
const desc = await (
  await fetch(BASE + "/products/prod_8f2/descriptions", { headers: h })
).json();

// Export a CSV
const csv = await (
  await fetch(BASE + "/export/catalog.csv?language=es", { headers: h })
).text();
Ejemplos — Bruxel