# create()

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

`api.models.create(options) → Promise<AssistantSession>`

Opens a model session. Four options decide everything that follows: which model, how it behaves, what shape it answers in, and whether it remembers.

Status: POST /api/ai/models · free — nothing is generated · returns an AssistantSession

Creating a session costs nothing and calls no model. It records a configuration; the first `generate()` is what spends.

## Parameters {#parameters}

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `model` | string | required | A model name from the [catalogue](/sdk/ref/iagenify/catalogue). Missing → the SDK throws before any request. |
| `settings` | object |  | How it behaves: instructions, temperature, output ceiling, server-side tools. See [settings](/sdk/ref/models/settings). |
| `schema` | object |  | A JSON Schema. Set it and the session answers objects instead of prose. See [schema](/sdk/ref/models/schema). |
| `memory` | boolean |  | Defaults to `true`. `false` means nothing is stored and each call starts from nothing. |
| `storage` | string |  | A storage id. The documents uploaded there become available to the session as context. |

## Returns {#returns}

```javascript
const assistant = await api.models.create({ model: "gemini-3.5-flash" });

assistant.id;         // keep this to reopen the session later
assistant.model;
assistant.settings;   // {}
assistant.schema;     // null
assistant.memory;     // true
assistant.title;      // "" until the first exchange names it
assistant.createdAt;
```

## memory, and what it changes {#memory}

This is the option people get wrong, because both values are reasonable and they are reasonable for opposite reasons.

|  | memory: true (default) | memory: false |
| --- | --- | --- |
| The conversation | Kept, and re-sent on each call | Not kept. Each call starts from nothing |
| Reopening later | get(id) carries on | There is nothing to carry on |
| Cost per call | Grows with the conversation, then settles | Flat |
| Good for | An assistant, a thread, anything with follow-ups | Classification, extraction, one-shot jobs at volume |

> **memory: false is not a privacy setting**
>
> It stops the conversation being stored and replayed. What you send still reaches the model to be answered. Decide what leaves your side on the input, not on this flag.

## What happens to a long conversation {#long}

A session with memory does not re-send an ever-growing history forever. Past a certain volume the older half is summarised once, the summary is kept with the session, and the recent messages follow it. The summary is redone only when the volume builds up again.

- That summary is itself a model call, so it is billed — once, not per answer.
- You do not trigger it and cannot turn it off; it is what keeps a long session from costing more every time.
- A session you intend to keep forever is fine. A session you intend to keep forever *and* replay verbatim is not what this is.

## storage, and what it is for {#storage}

Pass a storage id and the documents uploaded there are available to the session as context — the relevant passages are found and supplied with your question, rather than you pasting them in.

```javascript
const docs = await api.storage.get({ id: storageId });

const assistant = await api.models.create({
  model: "gemini-3.5-flash",
  storage: docs.id,
  settings: { instructions: "Answer only from the documents. Say so when they do not cover it." },
});

await assistant.generate({ inputs: [{ type: "text", content: "What is our refund window?" }] });
```

> **The instruction matters as much as the storage**
>
> Attaching documents makes them available; it does not stop the model answering from elsewhere. If you want it bounded to them, say so in instructions — and expect it to tell you when they do not cover the question.

## Errors {#errors}

| Code | Status | When |
| --- | --- | --- |
| — (thrown locally) | — | No model passed. The SDK throws before any request. |
| model_required | 400 | The model was empty by the time the server saw it. |
| unauthorized | 401 | No valid session or key on the call. |

A model name that is not in the catalogue is **not** refused here. Creating a session records a name; the refusal comes on the first `generate()`, which is where the model is actually asked for.

```javascript
// Check the name yourself if you want the failure early
const grid = await api.catalogue();
const known = grid.some((row) => row.model === wanted);
if (!known) throw new Error(`${wanted} is not in the catalogue`);
```

- [generate()](/sdk/ref/assistant-session/generate): Asking the session for something.
- [settings](/sdk/ref/models/settings): Instructions, temperature, ceiling, server-side tools.
- [schema](/sdk/ref/models/schema): Answering in a shape instead of in prose.

```python
assistant = api.models.create(model="gemini-3.5-flash")

assistant.id           # keep this to reopen the session later
assistant.model
assistant.settings     # {}
assistant.schema       # None
assistant.memory       # True
assistant.title        # "" until the first exchange names it
assistant.created_at
```

```python
docs = api.storage.get(id=storage_id)

assistant = api.models.create(
    model="gemini-3.5-flash",
    storage=docs.id,
    settings={"instructions": "Answer only from the documents. Say so when they do not cover it."},
)

assistant.generate(inputs=[{"type": "text", "content": "What is our refund window?"}])
```

```python
# Check the name yourself if you want the failure early
grid = api.catalogue()
if not any(row["model"] == wanted for row in grid):
    raise ValueError(f"{wanted} is not in the catalogue")
```
