Spark
Animation and 3D

Generating through an agent: MCP, API and renders over a 3D base

Topic 4513 min read + 2 hours for the taskRevised November 9, 2026

Image generation usually goes like this: open a website, write a prompt, download the file. Now an agent does the same thing: it picks the model, uploads the source image, runs six variants and puts them in the project folder. Generation stops being a one-off attempt. It becomes a pipeline step: you can repeat it, compare it and check it in code. Below are three ways to connect generation to an agent and a real case of mine: a hero shot of a countryside resort where the model is forbidden to move the river, the roads or the houses.

Three ways to give an agent generation

fal MCP server Phygital+ MCP server API script
What it is a remote MCP with a catalog of over a thousand models a remote MCP to your Phygital+ account: images, video, audio, 3D a Python file the agent writes itself and runs in the terminal
How to connect one command and sign-in through the browser one command and sign-in through the browser a FAL_KEY key in the .env file
How you pay fal balance, same price as the API Phygital+ subscription credits fal balance
Strength the agent finds the model itself and reads its parameters and price familiar models and a subscription you already pay for a run repeats one to one, settings live in git
When to use scouting: which model can handle the task you already have Phygital+ and one-off tasks series, batches and anything that will be redone

Connecting fal to Claude Code:

claude mcp add --transport http --scope user fal https://mcp.fal.ai/mcp-relay

Then type /mcp inside the agent and sign in to your fal account in the browser. You don’t need to paste a key anywhere. The server gives the agent eleven tools. The main ones: search_models and recommend_model find a model, get_model_schema shows its parameters, get_pricing gives the price, upload_file uploads the source image, run_model starts a generation. The server itself is free; you pay only for runs.

Connecting Phygital+ to Claude Code works the same way:

claude mcp add --transport http phygital https://dev.phygital.plus/api/mcp

Type /mcp, choose Authenticate and sign in with your regular Phygital+ login. In the browser you confirm which permissions the agent gets: start generations, upload files, read results. The second sign-in method is a personal API key from your account. You need it where there’s no browser, and you should treat it like a password.

The server has only a few tools, one per generation step. list_models shows the available models, get_model_schema the parameters of the chosen one. generate starts a job and returns its ID, get_job reports the status and returns links to the result, cancel_job cancels. Credits are charged when a job starts and refunded on cancellation. The agent uploads the source itself via upload_file, and you attach a file from your computer in a panel it opens right in the chat. The same server makes images, video, audio and 3D.

There’s also a ready-made plugin: the MCP server together with skills that explain the whole workflow to the agent.

claude plugin marketplace add phygitalism/phygital-plus-agent-plugin
claude plugin install phygital-plus@phygital-plus

The service itself is covered in the “Image generation” topic, in the section on aggregators.

The third path works without MCP. An agent with a terminal from the “CLI and terminal AI agents” topic writes a script with the fal-client library, and the request takes about ten lines:

import fal_client

url = fal_client.upload_file("base.png")
result = fal_client.subscribe("fal-ai/nano-banana-pro/edit", arguments={
    "prompt": PROMPT,
    "image_urls": [url],
    "seed": 23,
    "aspect_ratio": "16:9",
    "resolution": "2K",
    "output_format": "png",
})
image_url = result["images"][0]["url"]

You won’t have to write this code by hand; the agent writes it. You just need to be able to read it: which model, which input images, which seed and size. The key lives in .env, and .env is listed in .gitignore. Don’t paste the key into the chat; that’s a rule from the “Securing a vibe-coded project” topic.

The rule for choosing is the same as in the “An agent in Blender” topic. Through MCP you explore: try models, check prices, make one-off images. As soon as a task repeats, ask the agent to move the request that worked into a script. In the case study below, all generation runs through scripts.

What changes when the agent generates

  • Seed. A number that pins down the randomness. The same seed with the same prompt and source image gives a very similar result. That’s why a good variant can be regenerated at a larger size.
  • Series instead of attempts. The agent runs four to six variants with different seeds and assembles a contact sheet. You choose from a row instead of hitting “try again.”
  • A record of every run. Next to the image sit the prompt, seed, model and settings. Without that, you can’t repeat a good variant even a day later.
  • Checking in code. The result is a file on disk, and the agent can measure it. This is the biggest win, and the case study is built on it.
  • Price. The agent sees the price before a run. Ask it to name the price before each series.

Case study: a frame where you can’t move the river

The task: a hero image for the landing page of a countryside resort by a river in a mountain valley. An aerial view, as if from a drone. Investors will look at it, and they’ll compare the image with the master plan. So the river, the roads, the village and every house have to be exactly where they really are.

A regular prompt is useless here. The model will draw a beautiful valley, just not this one. So the principle is: the model doesn’t invent geometry. First a precise 3D base is built, the model only “repaints” it into a photo, and after each step a script checks that nothing has moved.

The whole pipeline: terrain data → building footprints from the master plan → 3D base in Blender → generation on fal → automatic check → refining small buildings → a “now and after” pair → 8K and a file with notes on the frame. The agent wrote each step as a separate script, and the order and rules live in the project’s CLAUDE.md.

The base: terrain, satellite and building blocks

The agent downloaded satellite imagery and an elevation map for the right rectangle. From them it made a terrain mesh and masks for water, forest and roads. The master plan came as a PDF. A script converted it into building footprints with real coordinates and aligned them using already built houses that are visible on the satellite image. Alignment accuracy is about two meters, and heights come from the number of floors.

Then the agent runs Blender without an interface, as in the “An agent in Blender” topic. The script builds the terrain with the satellite texture and places simple white building blocks on it. The camera and sun are set in a single config.json file. The output is one render and several utility maps.

Depth

A depth map of the same frame in shades of grey: the near slope at the bottom is almost white, the far ridges darken toward the horizon, the sky is black

Segmentation: water, forest, road

The frame segmented into flat colors: forest and grass in two shades of green, the river as a light blue strip at the bottom, the road as a grey line, the sky black
Utility maps from the same render. Depth shows what’s closer to the camera. Segmentation says where the water, forest and road are. Later the script uses the segmentation to check whether the river stayed in place. · Blender, bpy script

Besides the images, the script writes anchors.json: the coordinates of every object in the frame. The landing page uses them to place labels over the image. Labels, prices and names never go into the image itself: they’re a layout layer.

Generation: one pass over the whole frame

The base goes to Nano Banana Pro on fal along with two style references. The prompt is short, and almost all of it is about what not to do:

Keep the exact terrain, river, roads and building positions of image 1. Re-render it as a photorealistic aerial drone photo in the style and lighting of images 2 and 3: lush green forest, turquoise river, soft haze, late-afternoon sun. Do not add, move or remove buildings or roads. No text.

Reference images convey style better than words. Words describe only the content, and the prompt doesn’t change from run to run. Format 16:9, size 2K, four to six variants with different seeds.

BeforeA Blender render: a mountain valley from above, slopes covered in a satellite forest texture, a pale strip of river at the bottom, a village along it, and beyond the village rows of small white blocks in a clearing and a chain of larger blocks by the road.

The base from Blender. The white blocks stand according to the master plan.

AfterThe same frame as a drone photo: green slopes in evening light, a turquoise river, a village with colorful roofs, and in place of the white blocks a neighborhood of low-rise houses and a row of three-story buildings by the road.

The Nano Banana Pro result, seed 23. The river, roads and neighborhoods are in the same places.

The model changed the light, color and materials, while the terrain, riverbed and roads stayed the same. Each white block became one building. · Blender (base, Esri World Imagery satellite texture) → Nano Banana Pro on fal

Automatic check: three numbers instead of “looks about right”

Your eye lets you down here. The image is beautiful, and you won’t notice the riverbank shifting by twenty pixels. So every variant goes through a script with three checks:

  1. Riverbank. The water outline from the segmentation is compared with the edges in the result. It computes the share of riverbank points that landed within 8 pixels.
  2. Buildings. The same for the block outlines from the master plan. A house that moved or disappeared leaves its outline empty.
  3. Invented buildings. The script looks for large bright patches outside the master plan outlines. That’s how it catches high-rises that aren’t in the project.

The script also saves an image with the outlines overlaid, so the numbers can be checked by eye. Rejects get thrown out, and the best seed moves on. The final frame has 86% of the riverbank within 8 pixels.

Passed: outlines in place

A generated frame of the valley with thin pink lines over it: the outlines of the river, roads, village edges and neighborhoods match the image

Reject: a different river bend

Another generated frame: the river makes a sharp loop around a green headland with a settlement and ponds; the terrain and riverbed don’t resemble the original valley
On the left, a variant that passed the check: the pink outlines from the segmentation sit on the riverbank and the neighborhoods. On the right, a reject. The frame is beautiful, and that’s the trap: the model drew a different valley. · Nano Banana Pro, OpenCV check script

It’s the same trick as the red-green overlay in the “An agent in Blender” topic. The agent is bad at judging a match by eye and good at writing code that measures it.

Small objects: the model inflates them

In a wide shot a house takes up about ten pixels. The model draws it two to four times larger, and words in the prompt don’t help. First I tried redrawing the relevant areas with a mask. The result looked like a collage: the patch had its own light, its own sharpness and its own scale.

Masked patch

A close-up: a dozen large wooden chalets with a winding road on a bright green slope; at the bottom, the edge of the village with noticeably smaller houses

Generation in 4K

The same area: five-story buildings stand along the road, and on the right a grid of streets with small village houses

Blocks in the base, one pass

The same area in the overall light and haze: a row of low buildings by the road and a neighborhood of small houses, the same size as the village ones
Three attempts on the same area. The masked patch produced chalets twice the size of the village houses. Generating in 4K turned three-story houses into high-rises. The third worked: all the future buildings stand as blocks in the 3D base, and the frame is generated whole in one pass. · Nano Banana Pro on fal
A fragment of the frame with two redrawn areas: the patches with cottages are brighter and sharper than the surrounding forest, outlined by a clean edge, and the houses are larger than the village ones at the bottom of the frame.
This is what redrawing in pieces looks like. Each area has its own light and its own sharpness, and the edge is obvious at first glance. · Nano Banana Pro on fal, masked area redraw

If an object is still inflated, a second camera helps. In Blender you set up a camera with the same angle but three times closer. Generation runs through it, and the result is transferred into the wide shot by aligning shared ground points. The script smooths the brightness along the edge of the insert.

“Now and after” from one frame

The slider on the landing page needs a pair: the valley today and the valley after construction. Both images are made from one frame. In the “now” version, the future neighborhoods are replaced with today’s forest, and everything else matches pixel for pixel. That’s why the slider doesn’t jump.

BeforeThe valley from above in evening light: the river, the village along the bank, and beyond the village solid forest and a clearing.

Now: forest where the future neighborhoods will be.

AfterThe same frame: beyond the village a neighborhood of low-rise houses has appeared in the clearing, and a row of buildings by the road. The river, village and slopes are unchanged.

After: the development plan.

Two states of one frame. Only the plan areas differ. · Nano Banana Pro on fal, pair assembled by a script

8K and notes for the frame

The final variant was upscaled to 7680 × 4320 with the SeedVR2 model on fal. After the upscale, the check runs again: upscaling can also shift details.

A close-up fragment of the final frame: a row of low buildings along the road, a neighborhood of low-rise houses with yards, forest and the edge of the village at the bottom, soft evening light.
A fragment of the 8K frame. The new neighborhood is in scale with the village, and the road and forest edge are where they are on the base. · Nano Banana Pro → SeedVR2 on fal

Next to the image sits NOTES.md, the notes for the frame: model, seed, check results, the license for the imagery and known inaccuracies. Mine says, for example, that the terrain came from open data at a resolution of about 30 meters, so the riverbank is softer than the real one. You’ll need this file in a month, and the client needs it right away. It honestly says which parts of the image you can trust.

fal or Phygital+: a test on 48 images

At first it looked to me like Phygital+ “draws a different valley.” I tested this separately. One model, one source image and one prompt in both services, 48 images, four tests: a prompt in a non-English language (Russian, in my case), a very short prompt, fine details in the source image, and default settings.

There was no difference. The prompt reaches the model as written, the source image isn’t compressed, and the file size and geometry match. The “different valley” turned out to be one unlucky attempt. The differences were elsewhere. In the Phygital+ web interface you can’t set a seed for this model, so a good variant can’t be repeated. An image cost about 167 credits, which is 22–25 cents versus 15 on fal.

The takeaway applies beyond these two services. The model is the same; the wrappers differ. Choose the wrapper by what it lets you control: whether there’s a seed, whether you can run it from an agent, whether the settings are saved.

What it costs and where it breaks

Nano Banana Pro on fal costs 15 cents per image and 30 cents at 4K. The whole project, experiments included, came to about $25 in generations. The agent’s work on the scripts is counted separately, against your subscription limits.

  • Satellite imagery. Base maps have their own licenses. Either no original pixels of the imagery remain in the final frame, or you need to buy the base map. Note in NOTES.md, next to the frame, which base map you used and whether it can be published.
  • Small scale. The model inflates ten-pixel houses. The fix is blocks in the base and a second camera, not the prompt.
  • Patches. Redrawing in pieces produces a collage. Put everything into the base and do one pass.
  • Silent drift. Editing models sometimes shift the frame slightly. Without a check in code, you’ll find out from the client.
  • Time spent on the pipeline. The base and the checks pay off when precision matters more than speed: a master plan, architecture, a product with real dimensions. For a moodboard, a regular chat is enough.

Command examples for practice

Where to pasteClaude Code with the fal or Phygital+ MCP server connected
Find models that edit an image from a source image and accept a seed. Show them in a table: name, parameters, price per image at 2K. Don’t run anything
Upload base.png and generate four variants with seeds 1, 2, 3, 4 in the Nano Banana Pro Edit model, 16:9, 2K. Take the prompt from prompts/hero.md. Before running, tell me the total price and wait for my ‘yes’
Download all the results into out/gen/, one folder per variant. In each, put the image, prompt.txt and settings.json with the model, seed and size. Assemble a contact sheet of the four variants
Where to pasteClaude Code, Codex CLI or Gemini CLI with a terminal and the FAL_KEY key in .env
Move the request that worked in this session into a gen.py script using fal-client. Parameters: source image, seed, size, run name. Read the key from .env and never print it anywhere. Each run saves the image, prompt and settings into its own folder
Write checks.py: take the outlines from mask.png and compute what share of their points lie within 8 pixels of the edges in the generated image. Save an image with the outlines overlaid. Run it on all the variants in out/gen/ and show a table
Render a base for generation in Blender: the same frame, but in three files. base.png with materials, depth.png with depth, and mask.png with the silhouettes of objects that must not move. Put the camera and lighting in config.json
Upscale the best variant to 8K with the SeedVR2 model on fal and run checks.py again. Assemble NOTES.md: model, seed, check results, source licenses, known inaccuracies
Mini-task

Take a scene where the position of objects matters: the object from the “An agent in Blender” topic, a room blockout or a site plan. Render a base and a mask of what must not move. Connect fal or Phygital+ through MCP and generate four variants with different seeds over the base. Make sure each one has its prompt and settings next to it. Ask the agent to write a check: the share of mask outlines that matched the result, plus an overlay image. You’re done when the script has named the best variant and you can see on the overlay where the others drifted from the base.

Time: 1.5–2 hours
Done when: the agent generated four variants with different seeds over your base, each with its prompt and settings next to it, and the check script named the best variant and showed the outline overlay

Sources

  1. fal MCP Serverfal.ai

    Connecting to Claude Code, Codex and Cursor, sign-in through the browser, the server’s tool list and billing rules

  2. Phygital+ Dev Portal: MCP serverdev.phygital.plus

    Server address, two sign-in methods, tool list, file uploads and credit charging rules

  3. Phygital+ agent pluginsgithub.com

    A plugin with skills for the agent: installing in Claude Code and Codex

  4. Nano Banana Pro Edit on falfal.ai

    The model from the case study: request parameters, resolutions and price per image

  5. SeedVR2 Image Upscale on falfal.ai

    The upscaler that took the final frame to 8K

  6. Blender Python APIdocs.blender.org

    The bpy module: rendering the base, depth and masks from a script

Found a mistake or an outdated fact? Write to hey@iskra.guide