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.

@treza/ai-sdk on npm

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. 1

    Install it

    Add the package beside the AI SDK and Zod.

    npm
    npm install @treza/ai-sdk ai zod
  2. 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.

    Shell
    export TREZA_API_KEY="treza_live_..."
  3. 3

    Pass the tools to a model

    trezaTools returns an object of tools. Use it as tools, or spread it beside your own.

    TypeScript
    import { 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. 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.

    TypeScript
    trezaTools({ maxCostUsd: 1.0, waitSeconds: 50 })

What the tools do

  1. 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. 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. 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. 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.

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.