A minimal end-to-end example: generate a score, modify it, and render it to SVG.
const BASE = "https://yapscore.ai/api/v1";
const KEY = "ys_..."; // from Settings → API Keys
const headers = {
"Authorization": `Bearer ${KEY}`,
"Content-Type": "application/json",
};
// 1. Generate
const gen = await fetch(`${BASE}/generate`, {
method: "POST",
headers,
body: JSON.stringify({ prompt: "A 4-bar waltz in D minor" }),
});
const { musicxml } = await gen.json();
// 2. Modify
const mod = await fetch(`${BASE}/modify`, {
method: "POST",
headers,
body: JSON.stringify({ musicxml, prompt: "Add a forte at measure 1" }),
});
const { musicxml: modified } = await mod.json();
// 3. Render → SVG
const render = await fetch(`${BASE}/render`, {
method: "POST",
headers,
body: JSON.stringify({ musicxml: modified, page: 1 }),
});
const svg = await render.text(); // <svg ...>...</svg>