thelastapi
Get started free

Generate images and video from Claude Code

Use AI video and image models directly from Claude Code by connecting the thelastapi MCP server or using the CLI to generate and store assets.

On this page 7 sections

You can run AI video and image models from Claude Code by connecting the thelastapi MCP server or running the vibiz CLI in Claude Code's shell. Claude Code calls media generation tools to create images, animate still assets into video clips, and save the resulting files directly to your project's Files storage with permanent URLs. Everything runs on one key, with per-call metering and daily project budgets.

This guide covers how to connect Claude Code, how to generate images and short videos, how to animate still frames, and how to manage media assets from your terminal.

How to connect Claude Code to thelastapi

Claude Code connects to thelastapi in two ways: through the Model Context Protocol (MCP) or through the command-line interface. Both share the same underlying API and project context.

To set up MCP automatically, run this command in your terminal:

Terminal
vibiz mcp add --clients "Claude Code"
vibiz skills add --global

If you prefer to configure MCP manually, you can add either the remote HTTP transport or the local process runner:

Terminal
# Remote MCP connection (prompts for sign-in on first tool call)
claude mcp add --transport http vibiz https://thelastapi.dev/mcp

# Local MCP runner (uses your saved CLI login)
claude mcp add vibiz -- npx -y @vibiz/cli mcp

You can also pass a project configuration file named .mcp.json in your repository root:

JSON
{
  "mcpServers": {
    "vibiz": {
      "command": "npx",
      "args": ["-y", "@vibiz/cli", "mcp"],
      "env": { "VIBIZ_API_KEY": "${VIBIZ_API_KEY}" }
    }
  }
}

When connecting via remote MCP, Claude Code uses OAuth 2.1 with PKCE. The first time a media tool is invoked, your browser opens an Authorize page. You can approve the agent with Full access or choose a Limited key. A Limited key allows Claude Code to run AI models, generate media, create projects, and deploy code, but prevents it from reading production secrets or withdrawing live funds. For more on tool routing, see What is MCP, and how do you give Claude Code real tools? and the Agents documentation.

Generating images and animating them into video

Once connected, Claude Code has access to the vibiz_image_generate MCP tool and can execute media CLI commands.

1. Generating still images

You can ask Claude Code to create hero images, UI assets, or product photography. Behind the scenes, it executes vibiz image or invokes the media tool:

Terminal
vibiz image "A clean modern ceramic coffee cup on an oak desk, morning light" -o cup.png --size 1024x1024

To edit an existing picture or use an image as a visual reference, include --from-image:

Terminal
vibiz image "Turn the ceramic cup blue and add steam rising" -o cup-edited.png --from-image https://thelastapi.dev/files/prj_123/cup.png

2. Creating short video clips

Video models turn natural language prompts into motion clips. The default vibiz/video model generates six-second video files:

Terminal
vibiz video "Steam rising slowly from a warm ceramic cup on a wooden table" -o cup.mp4 --aspect 16:9

For vertical video suitable for mobile layouts or social previews, change the aspect ratio:

Terminal
vibiz video "Overhead view of coffee pouring into a ceramic mug" -o vertical.mp4 --aspect 9:16

3. Animate an image into video (Image-to-Video)

A reliable workflow for agents is creating a high-resolution still image first, verifying its composition, and then animating it. You pass the URL of the generated still directly into the video command:

Terminal
# Step 1: Generate the base image
vibiz image "A sailboat floating on calm ocean water at sunset" -o sunset.png

# Step 2: Animate the image using its permanent URL
vibiz video "Gentle ocean waves rocking the boat under evening light" \
  --from-image https://thelastapi.dev/files/prj_123/sunset.png \
  -o sunset-motion.mp4

Because every generated asset is hosted permanently in your project's Files storage, Claude Code can reference the returned URL immediately in frontend markup or subsequent animation prompts.

Choosing image and video models

thelastapi provides default aliases for standard tasks as well as direct access to specific lab models:

Model Alias / IDCategoryOutput / FocusNotes
vibiz/imageImage generationPNG / WebP imagesRuns Nano Banana 2
vibiz/image-textImage with textGraphical bannersRuns GPT Image
vibiz/videoVideo generationSix-second MP4 clipsText-to-video or image-to-video
Specific lab IDsVideo / TransformationCustom video modelsSelectable models like Kling, Seedance, Veo

To view every media model currently available on your account along with live per-call pricing, use vibiz media-models:

Terminal
vibiz media-models
vibiz media-models --category image-to-video

When targeting a specific model by name, pass the --model flag:

Terminal
vibiz video "Camera pans across an empty architectural gallery" -o gallery.mp4 --model kling

If you are coordinating other language and reasoning models in the same codebase alongside media generation, see Can you use Claude Code with other models? What a gateway can and cannot do.

Managing generated media assets

Agents often generate dozens of assets during a design or prototyping session. thelastapi stores all generated images, video clips, and audio files automatically inside the project's Files repository.

Claude Code can inspect and retrieve files without filling local storage:

Terminal
# List recent media generated for this project
vibiz files --since 4h --type video

# Get the permanent public link for the newest asset
vibiz files latest --type video

# Search for assets by the prompt words used to create them
vibiz files search "ceramic coffee cup"

# Download a specific remote asset locally
vibiz files download fil_abc123 -o ./public/hero.mp4

Each generated file record retains its input metadata, including the prompt, model, file size, and creation timestamp. If a file is no longer needed, deleting it removes the permanent URL:

Terminal
vibiz files rm fil_abc123

By retaining permanent URLs automatically, your agent can write clean HTML, React, or Svelte components that reference https://thelastapi.dev/files/... directly without running separate CDN upload scripts. Learn more about unified environment management in One API key for an AI agent: hosting, database, email, payments and models.

Controlling media budgets and usage limits

Image and video models cost more per call than standard text completions. To prevent autonomous agents from running up unplanned bills during iterative loops, set daily safety budgets.

You can configure caps at both the account level and the individual project level:

Terminal
# Set a daily spend ceiling for the entire account ($10 a day)
vibiz billing limit 10

# Set a strict daily AI budget for the active project ($3 a day)
vibiz ai budget 3

# View current spending and remaining limits
vibiz usage --period 24h --by tool
vibiz usage --by model

When an agent hits a daily budget limit, subsequent generation calls return an HTTP 429 error with details.reason: "project_budget" or "daily_spend". This halts further generation without crashing your application.

Permissions and environment separation

When deploying Claude Code across development and production branches, manage credentials with the Keys and environments workflow.

By default, running vibiz login assigns the CLI a Limited key named cli · <computer name>:

Terminal
vibiz login
vibiz whoami

A Limited key has permission to create development databases, test deployments, run scrapers, and execute AI image or video calls. However, it cannot read production database rows, expose production environment variables, or initiate money transfers.

When your agent needs access to project variables locally, run:

Terminal
vibiz dev

This writes the isolated development environment credentials to .env.development.local, including a project development key for AI media generation.

Review the CLI reference to explore flags for media generation, or follow the Quickstart to configure your first automated project.

Frequently asked questions

Where are the videos and images stored after generation?

Every media asset generated by an AI model is automatically saved in your project's Files storage with a permanent URL. You can inspect them using `vibiz files` or fetch the most recent link using `vibiz files latest`.

Can Claude Code animate an image that was generated in an earlier step?

Yes. You can pass the public URL of any previous image into `vibiz video` using the `--from-image <https url>` flag to create a six-second animated clip.

How can I stop Claude Code from exceeding a media generation budget?

Set a project-level daily limit using `vibiz ai budget <dollars>` or an account-level ceiling with `vibiz billing limit <dollars>`. Once reached, generation requests fail with a `429` rate-limit error naming the budget reason.

Does Claude Code need full access permissions to generate images and video?

No. A Limited API key created during `vibiz login` can execute all AI media commands and save files in development without needing access to production secrets or financial controls.