bruxel.ai

Exemples

Le flux d'intégration en curl, Python et JavaScript. Remplacez bxk_votre_cle par celle créée dans la console.

S'authentifier et vérifier

Chaque appel porte votre clé API comme jeton Bearer. Commencez par confirmer que ça marche avec 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, ... } }

Importer votre catalogue

Créez ou mettez à jour des produits par SKU (upsert en masse, jusqu'à 500 par requête).

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 }

Générer une description

Génération synchrone : facture au succès. L'Idempotency-Key est recommandé pour des nouvelles tentatives sûres.

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 }

Générer par lot

Pour le volume : réservez des crédits avec un Idempotency-Key obligatoire et faites du poll jusqu'à la fin du lot — le poll facture les succès et rembourse le reste.

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");

Lire et exporter

Lisez la description actuelle d'un produit ou exportez tout le catalogue généré en 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();
Exemples — Bruxel