Give your AI SDK app images and video
@treza/ai-sdk is an npm package of tools for the Vercel AI SDK. A model calls them from generateText, streamText or an agent to make a picture, make a video clip or run one of your Treza pipelines, and gets back the finished file's link and what it cost.
Free to add. You pay only for what you make.
Set it up in Vercel AI SDK
Install the package
Node.js 18 or newer, with AI SDK 5, 6 or 7. Run it on the server, so the API key never reaches the browser.
- 1
Install it
Add the package beside the AI SDK and Zod.
npmnpm install @treza/ai-sdk ai zod - 2
Add your Treza API key
Make a key on the Treza API keys page with the pipelines:read, pipelines:write and pipelines:run permissions. It starts with treza_live_. Set it as TREZA_API_KEY, or pass apiKey in your code.
Shellexport TREZA_API_KEY="treza_live_..." - 3
Pass the tools to a model
trezaTools returns an object of tools. Use it as tools, or spread it beside your own.
TypeScriptimport { generateText, stepCountIs } from "ai"; import { trezaTools } from "@treza/ai-sdk"; const { text } = await generateText({ model, // any AI SDK model that can call tools tools: trezaTools({ maxCostUsd: 1.0 }), stopWhen: stepCountIs(5), prompt: "Make a 4 second vertical clip of a fox in snow and give me the link.", }); - 4
On a serverless function, shorten the wait
A tool waits up to waitSeconds for a render. Set it under your function's time limit; a render still going comes back as running, and treza_get_run fetches it on a later request.
TypeScripttrezaTools({ maxCostUsd: 1.0, waitSeconds: 50 })
What the tools do
- 1
treza_generate_image and treza_generate_video
The model writes the prompt and picks the shape, and for video the length and whether it has sound. Links to pictures in your Treza library can be references for an image, or the first and last frame of a clip.
- 2
treza_run_pipeline
Starts a pipeline you built in Treza with the inputs the model passes in, and returns everything it made. Leave it out with includePipelines: false.
- 3
treza_get_run
Looks a render up by its IDs. A video that takes longer than the tool waits comes back as still running, not as an error, and this picks it up. Free.
- 4
treza_balance
The credits left on your Treza account. Free.
Apps to start from
Each one is trezaTools beside the model and tools you already use.
A chat that makes clips
A streamText route with trezaTools, so "make a 4 second vertical clip of a fox in snow" comes back as a finished MP4 link.
A picture, then the clip
The model makes a picture with treza_generate_image and passes its link as firstFrameUrl to treza_generate_video.
Your pipeline as a tool
treza_run_pipeline with a topic from the conversation as its input, and the finished video's link in the reply.
Only pictures
Pick one tool off the object, such as { treza_generate_image } = trezaTools({ maxCostUsd: 0.25 }), and pass just that.
Questions
What does it cost?
The package is free and MIT licensed. Renders spend prepaid credits from your Treza balance, with no subscription. Set maxCostUsd in your code: Treza prices the render first, and when the price is higher the tool tells the model so and nothing is spent.
Can the model raise the price cap?
No. maxCostUsd and the API key are set in your code and are not part of what the model sees or fills in. With no cap set, a render runs at its quoted price as long as your balance covers it, so set one.
What about videos that take minutes?
Each tool waits up to waitSeconds, 300 by default. A render still going after that comes back with status running and its IDs, and nothing is started twice. treza_get_run returns the file once it is done. If the request is aborted while a tool waits, the render is cancelled in Treza too.
Do I need an API key?
Yes. Your app runs without you signing in, so it uses a key from the API keys page instead of Google. Delete the key there to cut the app off.
Do my videos and credits carry over between apps?
Yes. Every app signs in to the same Treza account, so your library, your pipelines and your balance are the same in ChatGPT, Claude, Muse, Gemini, Cursor, Codex, Hermes Agent, Blender, n8n, Zapier, Dify, Gumloop and on trezalabs.com.
Treza in other apps
ChatGPT
In ChatGPT's plugin directory. Add it and mention @Treza in any chat.
Set it up->Claude
A custom connector in the Claude app, or the Treza plugin in Claude Code.
Set it up->Muse
Ask Muse to build a Treza connector, or add Treza to Muse Code.
Set it up->Gemini
A custom app in the Gemini app, or a server in Antigravity CLI.
Set it up->Cursor
One click adds Treza to Cursor's agent.
Set it up->Codex
From the plugin catalog in the ChatGPT app, or one command in Codex CLI.
Set it up->Hermes Agent
A few lines in ~/.hermes/config.yaml and one login command.
Set it up->Blender
An add-on that turns your camera view into AI renders and video clips.
Set it up->n8n
A verified node that makes images and videos inside your workflows.
Set it up->Zapier
Steps that make images and videos in your Zaps. In beta.
Set it up->Dify
A tool plugin that makes images and videos in your workflows and agents.
Set it up->ComfyUI
Nodes that make images and videos in your graphs, with no GPU needed.
Set it up->LangChain
Python tools that let an agent make images and videos, with a price cap.
Set it up->LlamaIndex
A tool spec that lets an agent make images and videos, with a price cap.
Set it up->CrewAI
Tools that let the agents in a crew make images and videos, with a price cap.
Set it up->Gumloop
A custom MCP server that lets your agents make images and videos.
Set it up->Any MCP client
One URL for every client that speaks Streamable HTTP MCP.
Set it up->Vercel AI SDK is a trademark of Vercel. Treza is an independent product and is not affiliated with or endorsed by Vercel.
Setup steps from @treza/ai-sdk on GitHub, AI SDK Docs: Tool calling.