1 · Install
npm install iagenify
# yarn add iagenifypython -m pip install iagenify2 · Point it at a key
The key is exchanged for a session on the first call and never sent again. Keep it server-side.
import { IaGenify } from "iagenify";
const api = new IaGenify({
apiKey: process.env.IAGENIFY_API_KEY, // ia_...
baseUrl: "https://api.iagenify.com", // or set IAGENIFY_API_URL instead
});
console.log(api.env, api.framework); // "node" "node"
console.log(await api.getUser()); // { id, email, credits, pack }import os
from iagenify import IaGenify
api = IaGenify(
api_key=os.environ["IAGENIFY_API_KEY"],
base_url="https://api.iagenify.com",
)
print(api.env, api.framework) # "python" "python"
print(api.get_user())
api.close()3 · Generate something
const assistant = await api.models.create({
model: "gemini-3.5-flash",
settings: { role: "Technical writer", instructions: "Answer in one paragraph." },
memory: true,
});
const result = await assistant.generate({
inputs: [{ type: "text", content: "What is an execution trail?" }],
});
console.log(result.outputs[0].content);
console.log(result.usage); // { credits: 4, inputTokens: 38, outputTokens: 96 }
await assistant.destroy();assistant = api.models.create(
model="gemini-3.5-flash",
settings={"role": "Technical writer", "instructions": "Answer in one paragraph."},
memory=True,
)
result = assistant.generate(inputs=[
{"type": "text", "content": "What is an execution trail?"},
])
print(result["outputs"][0]["content"])
print(result["usage"])
assistant.destroy()memory: true makes it a stored conversation. A test script that leaves them behind fills the account with conversations nobody opens.
Structured output instead of prose
Pass a JSON Schema and the answer comes back shaped. outputs[0].content is then a JSON string you parse.
const extractor = await api.models.create({
model: "gemini-3.5-flash",
memory: false,
schema: {
type: "object",
properties: {
company: { type: "string" },
amount: { type: "number" },
dueDate: { type: "string" },
},
required: ["company", "amount"],
},
});
const { outputs } = await extractor.generate({
inputs: [{ type: "text", content: invoiceText }],
});
const invoice = JSON.parse(outputs[0].content);import json
extractor = api.models.create(
model="gemini-3.5-flash",
memory=False,
schema={
"type": "object",
"properties": {
"company": {"type": "string"},
"amount": {"type": "number"},
"dueDate": {"type": "string"},
},
"required": ["company", "amount"],
},
)
response = extractor.generate(inputs=[{"type": "text", "content": invoice_text}])
invoice = json.loads(response["outputs"][0]["content"])Reading a file, a picture or a recording
Inputs are typed. Seven types are accepted: text, image, file, video, audio, speech and passages.
import { readFileSync } from "node:fs";
await assistant.generate({
inputs: [
{ type: "text", content: "What does this contract commit us to?" },
{ type: "image", url: "https://example.com/page-1.png" },
{ type: "audio", content: readFileSync("./meeting.m4a").toString("base64"), mime: "audio/mp4" },
],
});import base64
from pathlib import Path
result = assistant.generate(inputs=[
{"type": "text", "content": "What does this contract commit us to?"},
{"type": "image", "url": "https://example.com/page-1.png"},
{"type": "audio", "content": base64.b64encode(Path("meeting.m4a").read_bytes()).decode(), "mime": "audio/mp4"},
])4 · Then the part that matters
A model session answers questions. An agent does work: it reads, searches, edits, runs commands, and stops to ask before anything it cannot take back.
const pc = await api.storage.get(); // this computer, as a storage
const agent = api.agents.create({
runtime: "local",
machine: pc,
model: "gemini-3.5-flash",
mode: "ask", // ask · auto · plan · full
budget: 200, // credits; the run stops rather than overrun
onPermission: async ({ tool, args, category }) => {
console.log("asking for", tool, category);
return "once"; // "once" | "always" | "deny"
},
});
const run = await agent.run({
message: "Summarise every .md file in Notes/ into Notes/summary.md.",
onEvent: (e) => {
if (e.type === "text") process.stdout.write(e.delta ?? "");
if (e.type === "tool_start") console.log("\n→", e.tool, e.summary ?? "");
if (e.type === "done") console.log("\n", agent.usage);
},
});
console.log(run.text);
console.log(agent.usage); // { credits, turns, toolCalls }
console.log(agent.context); // { tokens, limit, window, cachedTokens, parts }machine = api.storage.get()
agent = api.agents.create(
runtime="local",
machine=machine,
model="gemini-3.5-flash",
mode="ask",
budget=200,
on_permission=lambda request: "once",
)
def on_event(event):
if event["type"] == "text":
print(event.get("text", ""), end="", flush=True)
elif event["type"] == "tool_start":
print("\n", event.get("tool"), event.get("summary", ""))
run = agent.run(
message="Summarize every .md file in Notes/ into Notes/summary.md.",
on_event=on_event,
)
print(run["text"])
print(run["usage"])Watching it think
Twelve event types arrive on onEvent. These five are what an interface is usually built from.
| Event | Carries |
|---|---|
| text | delta — the answer, streamed |
| tool_start | id, tool, args, summary, category |
| tool_end | id, tool, ok, summary, credits, durationMs |
| permission | the request your onPermission is answering |
| done | the run is over; agent.usage is final |