Skip to content
NorthstarPlatformPricingLogin
Integrations

Vercel AI SDK

Use Lightcone as a tool in Vercel AI SDK workflows.

Use Lightcone with the Vercel AI SDK to give your AI workflows the ability to browse and interact with web pages.

Terminal window
npm install ai @ai-sdk/openai @tzafon/lightcone
import { generateText, tool } from "ai";
import { createOpenAI } from "@ai-sdk/openai";
import Lightcone from "@tzafon/lightcone";
const lightcone = new Lightcone();
const tzafon = createOpenAI({
baseURL: "https://api.tzafon.ai/v1",
apiKey: process.env.TZAFON_API_KEY!,
});
const result = await generateText({
model: tzafon("tzafon.northstar-cua-fast"),
tools: {
browse: tool({
description: "Visit a URL and take a screenshot of the page",
parameters: {
url: { type: "string", description: "The URL to visit" },
},
execute: async ({ url }) => {
const computer = await lightcone.computers.create({ kind: "browser" });
const id = computer.id!;
await lightcone.computers.navigate(id, { url });
const result = await lightcone.computers.screenshot(id);
await lightcone.computers.delete(id);
return { screenshot: result.result?.screenshot_url };
},
}),
},
prompt: "Visit https://news.ycombinator.com and describe what you see",
});
console.log(result.text);

The Vercel AI SDK supports tool calling. Lightcone’s computer actions are wrapped as tools that the AI model can invoke during text generation. When the model decides it needs to visit a web page, it calls the browse tool, which:

  1. Creates a Lightcone computer session
  2. Navigates to the requested URL
  3. Takes a screenshot
  4. Returns the result to the model
  5. Terminates the session

You can extend this pattern with additional tools for clicking, typing, form filling, and data extraction.

  • Mastra — another TypeScript AI framework with Lightcone
  • LangChain — Python and TypeScript tools
  • Legacy software — automate enterprise applications