A summariser extension is a great first AI project, with one important rule: the API key must not be inside the extension. Extensions can be unpacked and read by anyone. Instead, the extension calls a small server you control.
1. The server (Node)
import express from "express";
import OpenAI from "openai";
const ai = new OpenAI({ baseURL: "https://devsaio.lol/v1", apiKey: process.env.DEVSAIO_API_KEY });
const app = express();
app.use(express.json({ limit: "200kb" }));
app.post("/summarise", async (req, res) => {
if (req.get("x-ext-token") !== process.env.EXT_TOKEN) return res.status(401).end();
const text = String(req.body.text || "").slice(0, 40000);
const r = await ai.chat.completions.create({
model: "claude-haiku-5-5",
max_tokens: 350,
messages: [{ role: "user", content: "Summarise this web page in 5 bullet points, then one line on who it's useful for:\n\n" + text }],
});
res.json({ summary: r.choices[0].message.content });
});
app.listen(8787);EXT_TOKEN is a simple shared secret for personal use. For a public extension, use real user accounts and per-user limits.
2. The extension
manifest.json:
{
"manifest_version": 3,
"name": "Page Summariser",
"version": "1.0",
"action": { "default_popup": "popup.html" },
"permissions": ["activeTab", "scripting"],
"host_permissions": ["https://your-server.example/*"]
}popup.js:
const [tab] = await chrome.tabs.query({ active: true, currentWindow: true });
const [{ result: text }] = await chrome.scripting.executeScript({ target: { tabId: tab.id }, func: () => document.body.innerText });
const r = await fetch("https://your-server.example/summarise", {
method: "POST", headers: { "Content-Type": "application/json", "x-ext-token": "YOUR_EXT_TOKEN" },
body: JSON.stringify({ text }),
});
document.getElementById("out").textContent = (await r.json()).summary;popup.html just needs <pre id="out">Summarising…</pre><script src="popup.js" type="module"></script>.
Load it in Chrome via Extensions → Developer mode → Load unpacked.
Claude, GPT, Gemini, DeepSeek, image and video models through one OpenAI- and Anthropic-compatible endpoint. Prepaid, pay only for what you use.