SDKs
The SDKs wrap the API: functions, runs, uploads, logs, outputs and webhook checks. Both have no dependencies.
The packages publish as @usejinn/sdk (npm) and usejinn.com/go (Go). Until they are on the registries, ask Jinn for the source, or use the CLI and the HTTP API.
TypeScript
import { Jinn, tar, untar } from "@usejinn/sdk";
const jinn = new Jinn({ key: process.env.JINN_KEY! });
const input = await jinn.upload(tar({ "ticket.json": JSON.stringify(ticket) }));
let run = await jinn.startRun("fnc_5d2a91c07e4b38f6a1d0c2e9", { prompt: "Answer this ticket.", input });
run = await jinn.wait(run.id);
if (run.state === "succeeded") {
const files = untar(await jinn.output(run));
console.log(new TextDecoder().decode(files["reply.md"]));
} else {
console.error(run.failure, run.detail);
}
It runs in Node 20 and later, Deno, Bun and browsers. verifyWebhook checks a webhook.
Go
c := jinn.New(os.Getenv("JINN_KEY"))
in, err := c.UploadFolder(ctx, "./ticket")
run, err := c.StartRun(ctx, "fnc_5d2a91c07e4b38f6a1d0c2e9", jinn.RunRequest{Prompt: "Answer this ticket.", Input: in})
run, err = c.Wait(ctx, run.ID)
if run.State == jinn.Succeeded {
err = c.DownloadOutput(ctx, run, "./result")
}
jinn.VerifyWebhook checks a webhook.