api.models

list()

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

账户的模型会话, 最近先使用过。 简单数据—— 这是盘点, 不是处理器 。

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.

参数

limitinteger

返回多少要返回。 默认为 30,上限为 100,从不低于 1.

上限上方的值被降低而不是拒绝, 所以要求1000个静悄悄的给你100个。没有光标:答案是“ 最新的 N ” , 清单屏幕需要这个。

返回值

[
  {
    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",
    }
]
这些不是辅助会话对象

没有生成。 使用 ID 获取 。 如果您想要在 - 列表 () 中进行 对话 , 请在 列表 () 中 显示 存在 的 。

标题,以及从何而来

第一个用户信息命名会话—— 缩到一条线, 剪切大约70个字符。 没有使用模型来制作, 所以它不花费任何费用, 并且它字面上比聪明, 从未使用过的会话有一个空的标题 。

顺序是活动, 不是创建

届会会由 updatedAt,所以您上次生成的是一个是第一个。通常列表应该显示这个列表;排序 createdAt 如果你想要按开放的顺序来

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"])

保持整洁

累积的会话: create() 包括试运行打开的,没有东西会为你而失效

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()
删除会话删除其信件

这就是问题所在, 并且不可逆转。 如果对话值得保留的话, 先读取历史 。