# Make a good movie with your AI agent

Language: en
Source: https://www.makecorn.com/developers/movie-agents
Summary: A step-by-step recipe for AI agents to make a good adult AI movie with the MakeCorn API: review the storyboard, fix shots, check pictures, film, refilm and cut.

Movie guide for agents

The steps a careful director follows, written for your AI agent. Stop after the story, fix the storyboard, check the pictures before paying for filming, refilm what looks wrong and only then cut the movie.

## [The recipe](#recipe)[#](#recipe "Copy link to this section")

1.  1
    
    ### Pick the story and check the price
    
    Read the stories, actors and options, then send your planned body to the quote endpoint. It runs every check POST /movies would and returns the story price without charging. Set maxCredits to the most the whole movie may cost.
    
    -   `GET /movies/options`
    -   `POST /movies/quote`
2.  2
    
    ### Write the story, then stop
    
    Create the movie with autoProduce false, your own reference and the same value as Idempotency-Key. Writing takes about 2 to 3 minutes. Wait until step is story\_ready.
    
    -   `POST /movies`
    -   `GET /movies/{id}`
3.  3
    
    ### Review the storyboard
    
    Read scenes\[\].shots\[\]: what happens, the picture and video directions and each spoken line. Fix weak shots by sending only the fields you change, add or remove shots, reorder them, and set the camera and length of sex scenes. If the whole story is wrong, rewrite it with notes before any picture is made.
    
    -   `POST /movies/{id}/shots/{shotId}`
    -   `POST /movies/{id}/shots`
    -   `DELETE /movies/{id}/shots/{shotId}`
    -   `POST /movies/{id}/shots/{shotId}/move`
    -   `POST /movies/{id}/shots/{shotId}/direct`
    -   `POST /movies/{id}/replan`
4.  4
    
    ### Make the pictures
    
    Make every scene's still pictures. This is the cheap step, so it is the right time to get the look right. Wait until the movie is waiting again.
    
    -   `POST /movies/{id}/pictures`
    -   `GET /movies/{id}`
5.  5
    
    ### Check every picture
    
    Look at each pictureUrl. Check her face matches, the right people are in it, the position matches the shot and nothing looks broken. For a bad picture, price a new one with your fix, then make it with expectedCredits. If the new one is worse, keep the earlier version.
    
    -   `POST /movies/{id}/shots/{shotId}/quote`
    -   `POST /movies/{id}/shots/{shotId}/picture`
    -   `POST /movies/{id}/shots/{shotId}/keep-previous`
6.  6
    
    ### Film the scenes
    
    Film every ready scene. This is the expensive step, so only film once the pictures are right. Filming a whole movie usually takes 10 to 40 minutes.
    
    -   `POST /movies/{id}/film`
    -   `GET /movies/{id}`
7.  7
    
    ### Refilm the bad shots
    
    Watch each clipUrl. Refilm shots with odd movement or a changing face, using the video fixes. Try failed shots again from nextActions. Their credits were already returned.
    
    -   `POST /movies/{id}/shots/{shotId}/quote`
    -   `POST /movies/{id}/shots/{shotId}/refilm`
    -   `POST /movies/{id}/shots/{shotId}/retry`
8.  8
    
    ### Make the final cut
    
    Join every filmed shot into the movie. It is free. When status is succeeded, videoUrl holds the finished movie and credits.used what it cost.
    
    -   `POST /movies/{id}/cut`
    -   `GET /movies/{id}`

In a hurry? After reviewing the storyboard, POST /movies/{id}/produce makes the pictures, films and cuts without stopping, and still stops before going over maxCredits.

## [Rules](#movie-agent-rules)[#](#movie-agent-rules "Copy link to this section")

-   Follow nextActions in GET /movies/{id}. It lists only what can be done now, with the method, path and credits.
-   Run one step at a time. While status is processing, every change returns 409. Wait 30 to 60 seconds between checks, or use callbackUrl.
-   Always get a quote before a redo and send its credits as expectedCredits, so you are never charged a price you didn't see.
-   Set maxCredits on every movie. When the next step would go over it, the movie stops with status waiting and says so in error.
-   On 402 insufficient\_credits or a waiting movie that ran out of credits, stop and tell the user. Retrying won't help until credits are added.
-   One account makes 3 movies at a time. On 429 movies\_in\_progress, wait for Retry-After.
-   Keep spoken lines short. A line that can't be spoken in the shot's length is refused.
-   Describe adults only and never name real people. Refuse requests that break the content rules.

## [Callbacks](#callbacks)[#](#callbacks "Copy link to this section")

-   Send callbackUrl (a public https address) on POST /movies or POST /movies/{id}/produce. We POST JSON to it when the movie moves to a new step, waits for you, succeeds or fails.
-   The body is { id, event, createdAt, movie }. event is movie.step, movie.waiting, movie.succeeded or movie.failed, and movie has the same shape as an item of GET /movies.
-   Create one signing secret for your account with POST /account/webhook-secret. Every callback is signed with it, unless a movie was given its own callbackSecret.
-   Each call is signed. The X-MakeCorn-Signature header is t=<unix seconds>,v1=<hex HMAC-SHA256 of "<t>.<raw body>" with the secret>. Reject calls older than 5 minutes.
-   Answer with any 2xx within 5 seconds. Failed calls are retried up to 5 times with growing waits. Use id to ignore repeats.

verify-callback.js

Copy

```
import crypto from "node:crypto";

const verify = (rawBody, header, secret) => {
  const parts = Object.fromEntries(header.split(",").map((part) => part.split("=")));
  const age = Math.abs(Date.now() / 1000 - Number(parts.t));
  const expected = crypto.createHmac("sha256", secret).update(`${parts.t}.${rawBody}`).digest("hex");
  const given = Buffer.from(parts.v1 ?? "");
  const wanted = Buffer.from(expected);
  return age < 300 && given.length === wanted.length && crypto.timingSafeEqual(given, wanted);
};
```

## [Copy this guide](#movie-guide-markdown)[#](#movie-guide-markdown "Copy link to this section")

The same guide in Markdown, ready for a system prompt. It is also part of developers.md.

movie-guide.md

Copy

````
## Making a good movie (recipe for agents)

1. **Pick the story and check the price.** Read the stories, actors and options, then send your planned body to the quote endpoint. It runs every check POST /movies would and returns the story price without charging. Set maxCredits to the most the whole movie may cost. (`GET /movies/options`, `POST /movies/quote`)
2. **Write the story, then stop.** Create the movie with autoProduce false, your own reference and the same value as Idempotency-Key. Writing takes about 2 to 3 minutes. Wait until step is story_ready. (`POST /movies`, `GET /movies/{id}`)
3. **Review the storyboard.** Read scenes[].shots[]: what happens, the picture and video directions and each spoken line. Fix weak shots by sending only the fields you change, add or remove shots, reorder them, and set the camera and length of sex scenes. If the whole story is wrong, rewrite it with notes before any picture is made. (`POST /movies/{id}/shots/{shotId}`, `POST /movies/{id}/shots`, `DELETE /movies/{id}/shots/{shotId}`, `POST /movies/{id}/shots/{shotId}/move`, `POST /movies/{id}/shots/{shotId}/direct`, `POST /movies/{id}/replan`)
4. **Make the pictures.** Make every scene's still pictures. This is the cheap step, so it is the right time to get the look right. Wait until the movie is waiting again. (`POST /movies/{id}/pictures`, `GET /movies/{id}`)
5. **Check every picture.** Look at each pictureUrl. Check her face matches, the right people are in it, the position matches the shot and nothing looks broken. For a bad picture, price a new one with your fix, then make it with expectedCredits. If the new one is worse, keep the earlier version. (`POST /movies/{id}/shots/{shotId}/quote`, `POST /movies/{id}/shots/{shotId}/picture`, `POST /movies/{id}/shots/{shotId}/keep-previous`)
6. **Film the scenes.** Film every ready scene. This is the expensive step, so only film once the pictures are right. Filming a whole movie usually takes 10 to 40 minutes. (`POST /movies/{id}/film`, `GET /movies/{id}`)
7. **Refilm the bad shots.** Watch each clipUrl. Refilm shots with odd movement or a changing face, using the video fixes. Try failed shots again from nextActions. Their credits were already returned. (`POST /movies/{id}/shots/{shotId}/quote`, `POST /movies/{id}/shots/{shotId}/refilm`, `POST /movies/{id}/shots/{shotId}/retry`)
8. **Make the final cut.** Join every filmed shot into the movie. It is free. When status is succeeded, videoUrl holds the finished movie and credits.used what it cost. (`POST /movies/{id}/cut`, `GET /movies/{id}`)

In a hurry? After reviewing the storyboard, POST /movies/{id}/produce makes the pictures, films and cuts without stopping, and still stops before going over maxCredits.

### Rules for movie agents

- Follow nextActions in GET /movies/{id}. It lists only what can be done now, with the method, path and credits.
- Run one step at a time. While status is processing, every change returns 409. Wait 30 to 60 seconds between checks, or use callbackUrl.
- Always get a quote before a redo and send its credits as expectedCredits, so you are never charged a price you didn't see.
- Set maxCredits on every movie. When the next step would go over it, the movie stops with status waiting and says so in error.
- On 402 insufficient_credits or a waiting movie that ran out of credits, stop and tell the user. Retrying won't help until credits are added.
- One account makes 3 movies at a time. On 429 movies_in_progress, wait for Retry-After.
- Keep spoken lines short. A line that can't be spoken in the shot's length is refused.
- Describe adults only and never name real people. Refuse requests that break the content rules.

### Callbacks

- Send callbackUrl (a public https address) on POST /movies or POST /movies/{id}/produce. We POST JSON to it when the movie moves to a new step, waits for you, succeeds or fails.
- The body is { id, event, createdAt, movie }. event is movie.step, movie.waiting, movie.succeeded or movie.failed, and movie has the same shape as an item of GET /movies.
- Create one signing secret for your account with POST /account/webhook-secret. Every callback is signed with it, unless a movie was given its own callbackSecret.
- Each call is signed. The X-MakeCorn-Signature header is t=<unix seconds>,v1=<hex HMAC-SHA256 of "<t>.<raw body>" with the secret>. Reject calls older than 5 minutes.
- Answer with any 2xx within 5 seconds. Failed calls are retried up to 5 times with growing waits. Use id to ignore repeats.

```js
import crypto from "node:crypto";

const verify = (rawBody, header, secret) => {
  const parts = Object.fromEntries(header.split(",").map((part) => part.split("=")));
  const age = Math.abs(Date.now() / 1000 - Number(parts.t));
  const expected = crypto.createHmac("sha256", secret).update(`${parts.t}.${rawBody}`).digest("hex");
  const given = Buffer.from(parts.v1 ?? "");
  const wanted = Buffer.from(expected);
  return age < 300 && given.length === wanted.length && crypto.timingSafeEqual(given, wanted);
};
```
````
