Genkit JS API reference
    Preparing search index...

    Interface AgentAPI<State>

    The transport-agnostic surface for talking to an agent. The same shape is returned by ai.defineAgent(...) on the server and by remoteAgent(...) on the client.

    interface AgentAPI<State = unknown> {
        abort(
            snapshotId: string,
        ): Promise<
            "failed"
            | "completed"
            | "pending"
            | "expired"
            | "aborted"
            | undefined,
        >;
        chat(init?: AgentInit<State>): AgentChat<State>;
        getSnapshot(
            lookup: string | SnapshotLookup,
        ): Promise<SessionSnapshot<State> | undefined>;
        loadChat(opts: SnapshotLookup): Promise<AgentChat<State>>;
    }

    Type Parameters

    • State = unknown

    Hierarchy (View Summary)

    Index

    Methods

    • Aborts a running snapshot. Requires a server store.

      Parameters

      • snapshotId: string

      Returns Promise<"failed" | "completed" | "pending" | "expired" | "aborted" | undefined>

    • Reads a snapshot without starting a chat. Requires a server store. Accepts a snapshotId string, or a lookup object ({ snapshotId } / { sessionId }).

      Parameters

      • lookup: string | SnapshotLookup

      Returns Promise<SessionSnapshot<State> | undefined>

    • Loads a server snapshot and returns a chat with history restored. Accepts either a snapshotId (an exact snapshot) or a sessionId (the session's latest snapshot).

      Parameters

      • opts: SnapshotLookup

      Returns Promise<AgentChat<State>>