AI

All AI calls go through a Supabase Edge Function — the provider key stays server-side. The configured model is used by default; pass model to any helper to override for a specific request.

Requires ChromeShip Pro

Upgrade to Pro to unlock AI.

Import

import { ai } from "@/integrations/ai";

ai.text — text responses

Ask for a text response. Good for summaries, classification, rewriting, translation.

const summary = await ai.text(pageContent, {
  instructions: "Summarize in 3 bullets."
});

ai.json — structured output

Extract structured data. Pass a JSON schema describing the shape you want back. Good for parsing unstructured text into typed objects.

const fields = await ai.json("Extract name and email from this email", {
  name: { type: "string" },
  email: { type: "string" },
});

ai.stream — streaming tokens

Stream tokens as they arrive. Good for chat UIs, real-time generation, or showing progress during long outputs.

await ai.stream("Write a poem about shipping code", (chunk) => appendToUI(chunk));

ai.embed — vector embeddings

Turn text into vectors. Good for semantic search, RAG, or finding similar documents.

const vectors = await ai.embed(["doc a", "doc b"]);

ai.request — advanced

Multi-turn conversations, tool-calling, multimodal inputs, model override. Prefer the simpler helpers above unless you need the extra control.

const result = await ai.request({
  messages: [{ role: "user", content: "..." }],
  tools: [...],
  model: "gpt-4o", // optional — overrides the configured default
});