api.models

get()

api.models.get(id) → Promise<AssistantSession>

Reapre una sessione da id, con sua configurazione e sua conversazione intacta. It's che fa un thread sopravviva a un reinizio.

GET /api/ai/models/:idfreethrows on 404
Using Python?

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

Parâmetros

idstringobrigatório

Id sessione, da assistant.id o de lista().

Retorno

Un AssistantSession, identica in natura a quanto create() ti dava: la stessa configurazion, id mesma, e la conversazione ancora dietro di essa.

// First run
const assistant = await api.models.create({ model: "gemini-3.5-flash" });
await db.save(userId, assistant.id);
await assistant.generate({ inputs: [{ type: "text", content: "My name is Zayd." }] });

// A week later, a different process
const again = await api.models.get(await db.load(userId));
await again.generate({ inputs: [{ type: "text", content: "What is my name?" }] });
// It knows — the conversation came back with the session.
# First run
assistant = api.models.create(model="gemini-3.5-flash")
db.save(user_id, assistant.id)
assistant.generate(inputs=[{"type": "text", "content": "My name is Zayd."}])

# A week later, a different process
again = api.models.get(db.load(user_id))
again.generate(inputs=[{"type": "text", "content": "What is my name?"}])
# It knows — the conversation came back with the session.
Id è la sola cosa che devi conservare

Todo il resto — model, configurazioni, schema, historis — è sul servidor. Met id a fianco a quels che la sessione appartiene, e ningun altro ha bisogno di persistere.

Erros

CódigoStatusQuando
session_not_found404Nessuna sessione di questo cont porta que id — incluso un malformat.

It throws plutôt que returning null, quindi una sessione mancante è una deroga a la cattura, non un valore a testar.

import { IaGenifyError } from "iagenify";

async function resume(api, id, model) {
  try {
    return await api.models.get(id);
  } catch (err) {
    if (err instanceof IaGenifyError && err.status === 404) {
      // Deleted, or belonging to another account. Start a fresh one.
      return api.models.create({ model });
    }
    throw err;
  }
}
from iagenify import IaGenifyError

def resume(api, session_id, model):
    try:
        return api.models.get(session_id)
    except IaGenifyError as error:
        if error.status == 404:
            # Deleted, or belonging to another account. Start a fresh one.
            return api.models.create(model=model)
        raise

Una sessione appartenente a un altro conto risponde la stessa 404: la consulta è mirat al chillant, per cui un conto non può raggiungere — o neppure detectare — sessiones di un altro.

Una sessione creata con memoria: false

Ancora existe e get() ancora lo restitue, perché la configurazion è registrata. Ciò che non è là è una conversazione: riaprendo esso dà-te i memès configurazion e una ardore in bianco.