Skip to content

Mode B: Server Vision Adapter

Mode B automatically sends captured screenshots to a backend route handler that analyzes the image with a Vision LLM and returns a textual description.

  1. User selects a region on the screen.
  2. Truden captures the image and POSTs it as multipart/form-data to your configured endpoint.
  3. Your server handler runs your custom analyze function using any AI SDK (Vercel AI SDK, OpenAI, Anthropic, OpenRouter, Gemini, Ollama).
  4. The server responds with { description: "..." }.
  5. Truden passes the description string to your client’s onResult(description) callback.
Client Snip ───► POST /api/truden ───► Vision LLM ───► { description } ───► Client onResult(text)
app/api/truden/route.ts
import { handler } from "truden/server";
import { openai } from "@ai-sdk/openai";
import { generateText } from "ai";
export const POST = handler({
analyze: async ({ image, prompt }) => {
const { text } = await generateText({
model: openai("gpt-4o"),
messages: [{ role: "user", content: [{ type: "image", image }, { type: "text", text: prompt }] }],
});
return text;
},
});