Give your LangChain agent images and video

langchain-treza is a Python package of tools for LangChain and LangGraph. An agent calls them 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.

langchain-treza on PyPI

Free to add. You pay only for what you make.

Set it up in LangChain

Install the package

Python 3.10 or newer, with langchain-core 0.3 or newer.

  1. 1

    Install it

    Add the package to the environment your agent runs in.

    pip
    pip install -U langchain-treza
  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 api_key when you build a tool.

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

    Call one tool

    Each tool returns JSON with the file's link, its status, the price and the model.

    Python
    from langchain_treza import TrezaGenerateVideo
    
    tool = TrezaGenerateVideo(max_cost_usd=1.00)
    print(tool.invoke({"prompt": "A red fox trots through fresh snow", "aspect_ratio": "9:16", "duration_sec": 4}))
  4. 4

    Or give them all to an agent

    TrezaToolkit builds every tool with one key and one price cap. Pass the list to your agent or bind it to your model.

    Python
    from langchain_treza import TrezaToolkit
    
    tools = TrezaToolkit(max_cost_usd=1.00).get_tools()

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 TrezaToolkit(include_pipelines=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.

Agents to start from

Each one is the toolkit plus the model and tools you already use.

A clip from a brief

An agent with treza_generate_video turns "a 4 second vertical clip of a fox in snow" into a finished MP4 link.

A picture, then the clip

The agent makes a picture with treza_generate_image and passes its link as first_frame_url 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.

A step in a LangGraph graph

A node that calls TrezaGenerateImage directly, with no model deciding, between a writer node and a publisher node.

Questions

What does it cost?

The package is free and MIT licensed. Renders spend prepaid credits from your Treza balance, with no subscription. Set max_cost_usd when you build a tool: Treza prices the render first, and when the price is higher the tool tells the model so and nothing is spent.

Can the agent raise the price cap?

No. max_cost_usd 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 for an agent.

What about videos that take minutes?

Each tool waits up to wait_seconds, 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.

Do I need an API key?

Yes. An agent 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 agent 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.

LangChain is a trademark of LangChain, Inc.. Treza is an independent product and is not affiliated with or endorsed by LangChain, Inc..

Setup steps from langchain-treza on GitHub, LangChain Docs: Tools.