Get an API key
Client

new IaGenify()

new IaGenify(options) → IaGenify

The one object you construct. It holds the address, the session, the detected runtime, and every resource hanging off it.

constructed onceno network on constructionthrows without a key
Using Python?

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

Construction does no I/O. Nothing is validated against the server, no session is exchanged, no file is read. The first call that needs an identity is what reaches the network — which is why a wrong key surfaces there, and not here.

  • It does not contact the server, so a bad baseUrl is silent until the first call.
  • It does not read the session cache — that is lazy, on first use.
  • It does detect the runtime, the capabilities and the framework, synchronously, from globals already present.
  • It does refuse immediately when it has neither a key nor a session store.

Parameters

apiKeystringrequired*

Your key. Required unless you pass a storage that already holds a session.

baseUrlstring

Where the API lives: https://api.iagenify.com. Set it here, or set IAGENIFY_API_URL and leave it out.

storageobject

A replacement session store — { read, write, clear }. See below and Session storage.

sessionPathstring

Node only. Where the session file goes instead of ~/.iagenify/session. One path per account.

appNamestring

Names the caller. It travels with the key exchange and takes part in the deduplication of concurrent exchanges.

timeoutinteger

Default deadline in milliseconds for the calls that have one. 0 removes it. See Timeouts.

No key and no storage is refused immediately

The constructor throws a plain Error, synchronously, before anything else is built. It is the one failure you get without awaiting — which makes it the one you can assert in a unit test without a server.

new IaGenify();
// Error: IaGenify requires an API key.

new IaGenify({ apiKey: "" });
// same — an empty string is not a key

new IaGenify({ storage: myStore });
// fine: no key, but a store that may already hold a session
IaGenify()
# ValueError: IaGenify requires api_key or a custom session storage.

IaGenify(api_key="")
# same — an empty string is not a key

IaGenify(storage=my_store)
# fine: no key, but a store that may already hold a session

What the instance carries

PropertyTypeWhat it is
baseUrlstringThe address that won: the one passed, else the one in the environment.
envstringnode · browser · worker · unknown
capabilitiesobjectWhat this runtime can do: shell, filesystem, persistentStorage, http
frameworkstringnode · next.js · gatsby · vite · browser

All three detections are read once, at construction, and never refreshed. Full tables on env · capabilities · framework.

The resources

Fourteen, each one a branch of this reference. They share the client, the session and the timeout — constructing the instance is what configures all of them.

ResourceWhat it reaches
api.authThe current session: end it, revoke another, update the profile.
api.keysAPI keys: list, create, revoke.
api.modelsModel sessions, and one stateless turn.
api.memoryThe agent's short notes, kept between sessions.
api.filesFiles on the account, and on the machine.
api.storageStorages: connect one, create one, register a device.
api.cloudUsage and add-ons for IaGenify Cloud.
api.toolsSearch, fetch, convert, documents, media — callable directly.
api.agentsAgents, and the skills and subagents they are given.
api.mcpMCP servers connected to the account.
api.workflowsWorkflows: define, run, resume.
api.domainsAttached domains and their DNS.
api.mailMailboxes, messages, contacts.
api.hostsSites, apps and functions put online.

Methods on the client itself

Four, and all four are cheap: no credit is spent and nothing is created.

await api.getUser();      // { id, email, credits, pack } — or null
await api.catalogue();    // every model the account can call, with its price
await api.getStorage();   // the account's default storage — or null
await api.session();      // { id, storageId } — or null before the first exchange
api.get_user()      # {"id", "email", "credits", "pack"} — or None
api.catalogue()     # every model the account can call, with its price
api.get_storage()   # the account's default storage — or None
api.session()       # {"id", "storageId"} — or None before the first exchange

Replacing the session store

The default store is picked from the runtime. Pass storage and yours is used instead — three async methods, and that is the whole contract.

const store = {
  // Optional: it travels with the key exchange. Defaults to "custom".
  storageType: "redis",

  async read() {
    const raw = await redis.get(`iagenify:${tenant}`);
    return raw ? JSON.parse(raw) : null;   // null when nothing is cached
  },
  async write(data) {
    await redis.set(`iagenify:${tenant}`, JSON.stringify(data));
  },
  async clear() {
    await redis.del(`iagenify:${tenant}`);
  },
};

const api = new IaGenify({ apiKey, storage: store });
import json

class RedisStore:
    # Optional: informational. Defaults to "custom".
    storage_type = "redis"

    def read(self):
        raw = redis.get(f"iagenify:{tenant}")
        return json.loads(raw) if raw else None   # None when nothing is cached

    def write(self, data):
        redis.set(f"iagenify:{tenant}", json.dumps(data))

    def clear(self):
        redis.delete(f"iagenify:{tenant}")

api = IaGenify(api_key=api_key, storage=RedisStore())
  • read() must answer null — not throw, not undefined — when there is nothing cached.
  • write() is handed the whole session object. Store it opaquely; the shape is not yours to interpret.
  • What you store is credential material. Give it the protection a token deserves, and never log it.
  • A store whose write() does not actually persist still works — it just exchanges the key on every call, which is slower and makes a new session each time.

Where to construct it

A server, one account

Build it once, at module scope, and import it. The session cache is shared inside the process anyway, so a second instance buys nothing.

// iagenify.js
import { IaGenify } from "iagenify";

export const api = new IaGenify({
  apiKey: process.env.IAGENIFY_API_KEY,
  baseUrl: process.env.IAGENIFY_API_URL,
  appName: "invoice-worker",
});
# iagenify_client.py
import os
from iagenify import IaGenify

api = IaGenify(
    api_key=os.environ["IAGENIFY_API_KEY"],
    base_url=os.environ.get("IAGENIFY_API_URL"),
    app_name="invoice-worker",
)

A server, several accounts

This is the case that needs care. Two clients sharing a session file overwrite each other, so give each one its own path — and its own appName if you want them told apart in a session list.

const clients = new Map();

function clientFor(tenant) {
  if (!clients.has(tenant)) {
    clients.set(tenant, new IaGenify({
      apiKey: secrets[tenant],
      sessionPath: `/var/lib/app/sessions/${tenant}`,
      appName: `worker-${tenant}`,
    }));
  }
  return clients.get(tenant);
}
clients = {}

def client_for(tenant):
    if tenant not in clients:
        clients[tenant] = IaGenify(
            api_key=secrets[tenant],
            session_path=f"/var/lib/app/sessions/{tenant}",
            app_name=f"worker-{tenant}",
        )
    return clients[tenant]
Two keys, one session path, is the mistake to avoid

Each client writes its session over the other's. Nothing is lost — the key is re-exchanged — but you get a new session on nearly every call, and session lists fill with short-lived entries. One path per account.

An isolate that does not persist

Where there is no durable storage, the session lives in memory for as long as the isolate does. Construct per request and let it exchange once; or hand it a store you control, and the session survives the isolate.

A page

Never construct this in a page with a real key

Anything shipped to a browser is readable by whoever opens it, and a key is the account. Build the client on your server, expose only the operations your app needs, and let the page call those.

Four things that look like bugs and are not

What you seeWhat it is
The constructor succeeded with a wrong keyNothing is verified at construction. The first call fails instead.
unreachable on every call in productionbaseUrl is not what you meant. Read api.baseUrl and compare.
A new session on every callThe session store is not persisting — a read-only disk, or a store whose write is a no-op.
api.env is node inside a pageA bundler shimmed process. Node is tested first, so it wins.