← Docs

Excel Office Scripts with Meridian

Call Meridian chat completions directly from Excel Office Scripts using the fetch API. Process spreadsheet data with AI inside your workbook.

LOCKRequires API key
async function main(workbook: ExcelScript.Workbook) {
  const sheet = workbook.getActiveWorksheet();
  const range = sheet.getUsedRange();
  const rows = range.getValues();

  const prompt = rows
    .map((row) => row.join("\t"))
    .join("\n");

  const response = await fetch(
    "https://api.meridian.sh/v1/chat/completions",
    {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        "Authorization": "Bearer YOUR_API_KEY",
      },
      body: JSON.stringify({
        model: "meridian-4",
        messages: [
          {
            role: "system",
            content: "You are a data analyst. Return clean CSV.",
          },
          {
            role: "user",
            content: `Analyze this spreadsheet data:\n\n${prompt}`,
          },
        ],
        temperature: 0.3,
      }),
    }
  );

  const json = await response.json();
  const result = json.choices[0].message.content;

  const outputSheet = workbook.addWorksheet();
  outputSheet.getRange("A1").setValue(result);
}

Paste this script into the Automate tab in Excel for the web. Replace YOUR_API_KEY with a key from your Meridian dashboard.

The script reads the active sheet, sends every row as tab-separated text, and writes the model response into a new worksheet. Adjust the system prompt to match your use case.

Meridian © 2026 — Enterprise AI infrastructure