# create()

Canonical URL: https://developers.iagenify.com/sdk/ref/agents/create/
Language: en

`api.agents.create(options) → LocalAgent | Agent`

Builds an agent from its options. Everything is validated here, nothing is sent — the object is ready and the account knows nothing about it yet.

Status: no request · strict validation · returns an object

## A local agent {#local}

```javascript
const agent = api.agents.create({
  runtime: "local",
  machine: pc,                      // required
  model: "gemini-3.5-flash",        // required
  mode: "ask",
  tools: ["read", "list", "glob", "grep", "write", "edit", "bash"],
  budget: 200,
  memory: true,
  onPermission: async ({ tool, category, args }) => "once",
  onQuestion: async ({ question }) => answer(question),
});
```

## What is required {#required}

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `runtime` | string |  | `"local"` for the engine in your process. Absent builds the [server-side agent](/sdk/ref/agent). |
| `machine` | ConnectedStorage | required | A computer, a phone, or a cloud workspace. See [machine](/sdk/ref/agents/options/machine). |
| `model` | string | required | Unless you pass `id`, in which case it comes from the session. |

## Every option {#all}

| Option | Default | Page |
| --- | --- | --- |
| `machine` · `workspace` | — | [machine](/sdk/ref/agents/options/machine) |
| `model` · `fallbackModels` · `thinking` · `maxOutputTokens` | — · [] · null · 16 000 | [model and thinking](/sdk/ref/agents/options/model) |
| `tools` · `skills` · `subagents` · `mcp` · `agent` | all · all · all · all · null | [tools and library](/sdk/ref/agents/options/tools) |
| `mode` · `onPermission` · `onQuestion` · `system` | `"ask"` · — · — · "" | [mode and permissions](/sdk/ref/agents/options/mode) |
| `budget` · `maxSteps` · `contextTokens` | null · 100 · 200 000 | [budget and context](/sdk/ref/agents/options/budget) |
| `media` | {} | [media](/sdk/ref/agents/options/media) |
| `memory` · `id` · `memories` · `checkpoints` | false · — · true · true | [memory and sessions](/sdk/ref/agents/options/memory) |
| `files` · `shell` · `terminals` · `customTools` | — | [bridges](/sdk/ref/agents/options/bridges) |

## What is refused, and when {#refusals}

| Code | When |
| --- | --- |
| machine_required | No `machine`, or one that is not a computer, a phone or a cloud workspace. |
| files_required | A phone or a cloud workspace without the six file operations. The message names the missing ones. |
| model_required | No `model` and no `id`. |
| invalid_mode | A mode outside the four. |
| unknown_tool | A tool name the engine does not know. The message lists the ones it does. |
| invalid_context | `contextTokens` that is not a whole number of at least 10 000. |
| invalid_shell | A `shell` without a `run` function. |
| invalid_custom_tool | A custom tool with no description, no `run`, a reserved name, or a category outside the four. |
| invalid_media | A `media` key that is not `image`, `video`, `voice` or `music`. |
| invalid_agent | An `agent` name that is not a library name. |
| invalid_session_id | An `id` that is not a session identifier. |
| workspace_not_allowed | A `workspace` other than the SDK's own folder. |

> **All of them throw at creation, not at run time**
>
> That is deliberate: a misconfigured agent should fail on the line that configures it. The one exception is contextTokens being larger than the model's window, which needs the catalogue and therefore surfaces on the first run.

- [get()](/sdk/ref/agents/get): Reopening instead of creating.
- [LocalAgent](/sdk/ref/local-agent): Every property and method.
- [Agent engine](/sdk/agent): How the loop works.

```python
agent = api.agents.create(
    runtime="local",
    machine=pc,                       # required
    model="gemini-3.5-flash",         # required
    mode="ask",
    tools=["read", "list", "glob", "grep", "write", "edit", "bash"],
    budget=200,
    memory=True,
    on_permission=lambda request: "once",
    on_question=lambda request: answer(request["question"]),
)
```
