api.models

list()

api.models.list({ limit }) → Promise<Session[]>

The account's model sessions, most recently used first. Plain data — this is the inventory, not the handle.

GET /api/ai/modelsfreeplain objects
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

Parameters

limitinteger

How many to return. Defaults to 30, capped at 100, never below 1.

A value above the cap is lowered rather than refused, so asking for a thousand quietly gives you a hundred. There is no cursor: this answers « the most recent N », which is what an inventory screen needs.

Returns

[
  {
    id: "…",
    model: "gemini-3.5-flash",
    storage: null,
    settings: { instructions: "…" },
    schema: null,
    memory: true,
    title: "Résume ce contrat.",
    createdAt: "2026-10-01T09:12:44.102Z",
    updatedAt: "2026-10-07T11:02:08.400Z"
  }
]
[
    {
        "id": "…",
        "model": "gemini-3.5-flash",
        "storage": None,
        "settings": {"instructions": "…"},
        "schema": None,
        "memory": True,
        "title": "Résume ce contrat.",
        "createdAt": "2026-10-01T09:12:44.102Z",
        "updatedAt": "2026-10-07T11:02:08.400Z",
    }
]
These are not AssistantSession objects

There is no generate() on them. Take the id and pass it to get() when you want to carry a conversation on — list() is for showing what exists.

title, and where it comes from

The first user message names the session — trimmed to one line, cut at about seventy characters. No model is called to produce it, so it costs nothing and it is literal rather than clever. A session that has never been used has an empty title.

The order is activity, not creation

Sessions come back sorted by updatedAt, so the one you last generated in is first. That is usually what a list should show; sort on createdAt yourself if you want them in the order they were opened.

const sessions = await api.models.list({ limit: 50 });

// What a user would recognise
for (const s of sessions) {
  const when = new Date(s.updatedAt).toLocaleDateString();
  console.log(`${s.title || "(empty)"} · ${s.model} · ${when}`);
}

// Sessions that were opened and never used
const unused = sessions.filter((s) => !s.title);

// Carry one on
const assistant = await api.models.get(sessions[0].id);
from datetime import datetime

sessions = api.models.list(limit=50)

# What a user would recognise
for s in sessions:
    when = datetime.fromisoformat(s["updatedAt"].replace("Z", "+00:00")).date()
    print(f"{s['title'] or '(empty)'} · {s['model']} · {when}")

# Sessions that were opened and never used
unused = [s for s in sessions if not s["title"]]

# Carry one on
assistant = api.models.get(sessions[0]["id"])

Keeping it tidy

Sessions accumulate: every create() leaves one, including the ones a test run opened. Nothing expires them for you.

const sessions = await api.models.list({ limit: 100 });
const month = Date.now() - 30 * 24 * 60 * 60 * 1000;

const stale = sessions.filter(
  (s) => !s.title && Date.parse(s.updatedAt) < month,   // opened, never used, and old
);

for (const s of stale) {
  await (await api.models.get(s.id)).destroy();
}
from datetime import datetime, timedelta, timezone

sessions = api.models.list(limit=100)
month = datetime.now(timezone.utc) - timedelta(days=30)

stale = [s for s in sessions   # opened, never used, and old
         if not s["title"] and datetime.fromisoformat(s["updatedAt"].replace("Z", "+00:00")) < month]

for s in stale:
    api.models.get(s["id"]).destroy()
Deleting a session deletes its messages

That is the point, and it is not reversible. Read getHistory() first if the conversation was worth keeping.