Creating a session costs nothing and calls no model. It records a configuration; the first generate() is what spends.
Parameters
modelstringrequiredA model name from the catalogue. Missing → the SDK throws before any request.
settingsobjectHow it behaves: instructions, temperature, output ceiling, server-side tools. See settings.
schemaobjectA JSON Schema. Set it and the session answers objects instead of prose. See schema.
memorybooleanDefaults to true. false means nothing is stored and each call starts from nothing.
storagestringA storage id. The documents uploaded there become available to the session as context.
Returns
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;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_atmemory, and what it changes
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 |
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
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
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.
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?" }] });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?"}])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
| 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.
// 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`);# 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")