# generate

URL: /business/nouns/file/generate · Id: `verb:File.generate` · Call: `await $.File.generate({ … })` (SDK) or the `do` tool at `https://api.sb/mcp`. Inputs says what to pass, Outputs what returns, When it waits who approves.

> Generate makes an image, video, speech or music File from a prompt and reference Files, and records how it was made.

Generate makes an image, video, speech or music [File](/business/nouns/file) from a prompt and reference Files, and records how it was made.

## Inputs
| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `kind` | `string` | Yes | What to make. |
| `prompt` | `text` | Yes | What to make, or for `speech` the text to speak. |
| `references` | list of [File](/business/nouns/file) | No | Files the output follows, such as a product photo or a first frame. |
| `voice` | [Voice](/business/nouns/voice) | No | The Voice that speaks, for `speech`. |
| `format` | `json` | No | Aspect ratio, resolution, duration and file type. |

## Outputs
| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `file` | [File](/business/nouns/file) | Yes | The generated File, its bytes in Storage and its provenance recorded. |

## Effects
- Emits [`File.generated`](/business/events/File.generated).
- Performed by the [Content Lead](/agents/marketing/content-lead).
- Two-way: it runs at once, in the `try`, `send` and `do` modes.
- Runs as a background Action that waits with reason `running` until the upstream finishes.
- Copies the result bytes into Storage before the Action is `done`; an upstream link is never the record.
- Posts no Cost when generation fails and ends `refused` when the upstream declines the prompt.
- Canceling the Action cancels the upstream task.

## Refuses when
| Check | Error | Fix | Then call |
| --- | --- | --- | --- |
| The key is valid, but its scopes do not allow this operation. | [`forbidden`](/code/api/errors/forbidden) | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | [File.generate](/business/nouns/file/generate) |

## When it waits
| Gate | Default |
| --- | --- |
| Decision class | Low: two-way, nothing at stake |
| [Delay window](/systems/trust-and-governance/controls/one-way-windows) | None: it runs once review passes. |
| Limit | The call [Limit](/business/nouns/limit) of the [Permission](/business/nouns/permission) it runs under. |
| Over the Limit | It waits `pending` for an [Approval](/business/nouns/approval) from the [Founder](/agents/founding/founder). Approved, it runs; refused, it ends `refused` with [`limit-exceeded`](/code/api/errors/limit-exceeded); unanswered by its deadline, it ends `canceled`. |

## Example

**Ask**

```text
Generate the latest file.
```

**API**

```bash
curl -X POST https://api.sb/patentpad.com/files/generate \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"kind":"image","prompt":"Example prompt"}'
```

```json
{
  "api": "https://api.sb/patentpad.com",
  "file": {
    "$id": "https://api.sb/patentpad.com/files/file_1",
    "$type": "File",
    "contentType": "Example content type",
    "size": 1
  },
  "action": {
    "$id": "https://api.sb/patentpad.com/actions/action_1",
    "operation": "File.generate",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/patentpad.com/actions/action_1"
  }
}
```

**SDK**

```ts
import { $ } from 'startup-builder'

const file = await $.File.generate({ kind: 'image', prompt: 'Example prompt' })
```

**CLI**

```bash
npx startup-builder do File.generate --json '{"kind":"image","prompt":"Example prompt"}'
```

**MCP**

```json
{
  "name": "do",
  "arguments": {
    "code": "return await $.File.generate({ kind: 'image', prompt: 'Example prompt' })"
  }
}
```