Concepts

The HTTP client

One client underneath every resource. It attaches the session, carries the machine headers, parses the answer, and turns a failure into a typed error before you ever see it.

one instance per IaGenifytyped failures
Using Python?

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

You rarely touch it directly — api.models, api.storage and the rest all go through it. Knowing what it does is still worth a page, because its behaviour is what you are debugging when a call does something unexpected.

What happens on every call

StepWhat it does
1 · SessionGets a valid JWT, refreshing or exchanging the key if needed. Skipped for the few calls that need no identity.
2 · HeadersAdds the version, the machine id and the detected resources.
3 · BodyJSON, unless you passed FormData — then the Content-Type is left to the runtime.
4 · TimerAborts after the timeout, unless the timeout is 0.
5 · ParseJSON when it can; otherwise the raw text, as { msg }.
6 · FailureOne retry on 401, then a typed error carrying status, code and details.

A response that is not JSON

The client never throws on a body it cannot parse. A non-JSON success comes back as { msg: "…" } instead, which is what you will see if something between you and the API answers in its place — a proxy, a captive portal, an error page from a gateway.

const result = await assistant.generate({ inputs });

if (result.msg !== undefined && result.outputs === undefined) {
  // Something answered, but it was not the API
  console.error("unexpected body:", result.msg.slice(0, 200));
}
result = assistant.generate(inputs=inputs)

if "msg" in result and "outputs" not in result:
    # Something answered, but it was not the API
    print("unexpected body:", str(result["msg"])[:200])

Uploads

When a body is FormData, the client does not set Content-Type. That is deliberate: the boundary is generated by the runtime, and setting the header by hand produces a body the server cannot split.

Pointing it somewhere else

// Explicit
const api = new IaGenify({ apiKey, baseUrl: "https://api.iagenify.com" });

// From the environment
// IAGENIFY_API_URL=https://api.iagenify.com
const api = new IaGenify({ apiKey });

api.baseUrl;   // whichever won
# Explicit
api = IaGenify(api_key=api_key, base_url="https://api.iagenify.com")

# From the environment
# IAGENIFY_API_URL=https://api.iagenify.com
api = IaGenify(api_key=api_key)

api.base_url   # whichever won

With neither, the client has no address to call and every request fails with unreachable. In a deployed service, baseUrl is the first thing to check: read api.baseUrl and confirm it is https://api.iagenify.com.