orkhub-sdk
v0.1.1
Published
Official TypeScript/JavaScript SDK for Orkhub — run AI agents from your app.
Maintainers
Readme
orkhub-sdk
Official TypeScript/JavaScript SDK for Orkhub — run AI agents from your app.
Install
npm install orkhub-sdkQuick start
import { Orkhub } from "orkhub-sdk";
const ork = new Orkhub({ apiKey: process.env.ORKHUB_API_KEY! });
// Run an agent
const { response, tasks_used, tasks_limit } = await ork.agents.run(
"meeting-prep",
"Zoom call with Acme Corp tomorrow"
);
console.log(response);
console.log(`Used ${tasks_used}/${tasks_limit} tasks this month.`);Get your API key at orkhub.vercel.app/dashboard.
Running a workflow (chain of agents)
const { runId } = await ork.workflows.run("meeting-prep-pipeline", "Acme call tomorrow");
let run;
do {
await new Promise((r) => setTimeout(r, 2000));
run = await ork.workflows.getRun(runId);
} while (run.run.status === "running");
console.log(run.run.final_output);Listing agents
const { agents } = await ork.agents.list({ query: "sales" });
agents.forEach((a) => console.log(a.slug, "—", a.name));Error handling
Every failed call throws OrkhubError with .status, .code, and .message:
import { Orkhub, OrkhubError } from "orkhub-sdk";
try {
await ork.agents.run("meeting-prep", "...");
} catch (err) {
if (err instanceof OrkhubError) {
if (err.code === "quota_exceeded") {
// upgrade the hire
} else if (err.code === "hire_required") {
// direct the user to orkhub.vercel.app/agents/<slug> to activate
}
}
throw err;
}Runtime support
Node 18+, Deno, Bun, modern browsers. Zero dependencies — uses the global fetch.
For Node < 18, pass your own fetch:
import nodeFetch from "node-fetch";
const ork = new Orkhub({ apiKey: "...", fetch: nodeFetch as unknown as typeof fetch });License
MIT
