Build agents in Python

Vidbyte SDK

vidbyte-sdk is a free, MIT-licensed Python library (Python 3.11+, pip install vidbyte-sdk, alpha) for building, evaluating, and tracing your own AI agents: agents and tools, middleware such as a per-run US-dollar spending cap and context compaction, evals, multi-agent pipelines, tracing, and a local MCP server. Agent types include Agent, CodingAgent, InfiniteMemoryAgent, CodexHarnessAgent, and JevAgent, and by default they call models through Vidbyte's model gateway with a Vidbyte API key, or straight through your own model provider account with model_mode=TextModelMode.DIRECT.

What you can build with the SDK

The SDK runs on your computer, inside your own Python project. By default every model call goes through Vidbyte's model gateway with your Vidbyte API key. If you also hold your own provider key, the gateway passes it on, that provider bills you, and Vidbyte charges a 2% fee to your Vidbyte API balance; without one, Vidbyte pays the provider and bills your balance the provider's rate plus 2%. With model_mode=TextModelMode.DIRECT, the agent calls the provider straight with your own key and Vidbyte charges nothing.

  • Agents — Give a model a name, instructions, and a provider, then send it a task with run().

  • Tools — Let an agent call your own Python functions, search the web, or read files.

  • Teams of agents — Chain focused agents together so each one handles one part of a larger job.

  • Spending caps — Stop a run at a US-dollar limit with AgentLoopSettings(max_spend_usd=0.50) (vidbyte-sdk 0.4.0+). The SDK checks spend before each model and tool call, so one step can go slightly past the limit. It works on linear runtimes with models the SDK's price list can price; MCTS search, the actor-model runtimes, and CodexHarnessAgent refuse it with a ConfigurationError.

  • Guardrails — Add retries and safety checks that apply to every run.

  • Evaluations — Test an agent against example tasks and score its answers before you ship it.

Install it and run your first agent

Five steps take you from an empty folder to an agent that prints its answer in your terminal.

  1. Install the SDK

    Install vidbyte-sdk from PyPI. A virtual environment keeps it separate from your other projects.

    Install

    bash
    python -m pip install vidbyte-sdk
  2. Create a Vidbyte API key and add balance

    Agents send model calls through Vidbyte's model gateway by default, so they need a Vidbyte API key. Create one with the default permissions under Settings → API → Keys and copy it right away, then add a little API balance on the Usage page.

  3. Set your keys

    Set VIDBYTE_API_KEY in the terminal you will run the agent from. Your own OPENAI_API_KEY is optional: with it, OpenAI bills you for the model and Vidbyte charges a 2% fee; without it, Vidbyte bills your balance OpenAI's price plus 2%. On Windows PowerShell, use $env:VIDBYTE_API_KEY = "vb_live_your-key".

    macOS or Linux

    bash
    export VIDBYTE_API_KEY="vb_live_your-key" export OPENAI_API_KEY="your-openai-key" # optional: OpenAI bills you, Vidbyte adds 2%
  4. Write your agent

    Create a file called agent.py. The agent gets a name, short instructions, a provider, and a model.

    agent.py

    Python
    1from vidbyte import VidbyteSDK 2 3agent = VidbyteSDK().agents.base( 4 name="retry-reviewer", 5 system_prompt="Compare engineering options against the stated constraints.", 6 provider="openai", 7 model_name="gpt-5.5", 8) 9reply = agent.run("Compare backoff with jitter and fixed retries.") 10print(reply.content)
  5. Run it

    Run the file. The agent sends the task to the model and prints its answer in your terminal.

    Run

    bash
    python agent.py
What do I need to run it?

Python 3.11 or newer, a Vidbyte API key with the models:invoke permission (a key created with the default permissions has it), and some API balance. Since vidbyte-sdk 0.4.0 every agent defaults to TextModelMode.AUTO, which sends model calls through Vidbyte; without VIDBYTE_API_KEY a run stops with "Missing Vidbyte API key" before any request. A model provider key is optional. JevAgent always needs the Vidbyte key, because its Jev calls run through Vidbyte. The Codex and Claude Code harness agents are the exception: they run the Codex or Claude Code CLI on your own sign-in and need no Vidbyte key.

Can I run it with only my own provider key?

Yes. Pass model_mode=TextModelMode.DIRECT and the agent calls the provider straight with your own key, such as OPENAI_API_KEY: no Vidbyte account, key, or balance, and no Vidbyte fee. It is also the only mode that streams, reaches providers the gateway does not serve (the gateway serves OpenAI, Anthropic, Gemini, xAI, DeepSeek, and Kimi), or uses a custom endpoint.

agent.py, provider key only

Python
1from vidbyte import TextModelMode, VidbyteSDK 2 3agent = VidbyteSDK().agents.base( 4 name="retry-reviewer", 5 system_prompt="Compare engineering options against the stated constraints.", 6 provider="openai", 7 model_name="gpt-5.5", 8 model_mode=TextModelMode.DIRECT, # straight to OpenAI with OPENAI_API_KEY, no Vidbyte key or fee 9) 10reply = agent.run("Compare backoff with jitter and fixed retries.") 11print(reply.content)
What does it cost?

The SDK itself is free and MIT-licensed. In the default mode each model call carries a 2% Vidbyte fee: when your own provider key is passed on, the provider bills you for the model and Vidbyte bills only the fee to your API balance; otherwise Vidbyte bills your balance the provider's rate plus 2%. In TextModelMode.DIRECT the provider bills you and Vidbyte charges nothing. JevAgent's Jev calls are billed to your API balance at Jev's rate plus a 10% markup on each run.

Can I cap what an agent run spends in US dollars?

Yes. Set AgentLoopSettings(max_spend_usd=...) in vidbyte-sdk 0.4.0 and later. The runtime checks the run's measured spend between steps and stops once it reaches the cap, so treat it as a threshold, not a maximum bill: a step already under way can finish past it. The linear, Jev, and infinite-memory runtimes enforce it. An agent on any other runtime, or on a model the SDK cannot price, is refused when you create it, before it spends anything.

Does vidbyte-sdk include evals and an MCP server?

Yes. EvalCase, EvalSuite, and EvalRunner test an agent against example tasks and score its answers. McpStudioServer exposes the agents, tools, and prompts you register as MCP tools over stdio, so MCP clients such as Codex and Claude can call them; start it from a short launcher script that registers your agents. The vidbyte-mcp-server command installed with the SDK starts the same server with nothing registered.

Add a decision layer with JevAgent

JevAgent pairs your agent with Jev, a decision model that makes quick judgment calls during a run: whether a request is clear enough to start, which specialist should take it, and whether the work is really finished. It is in preview, and its capabilities are rolling out one at a time.

Next steps