Skip to the content
Krizaka TypeScript
Krizaka TypeScript

@krizaka/orazaka-client

One Orazaka client for the TypeScript products: start a run, read its status and outputs, typed errors, a time limit and a circuit breaker.

Install

bashTerminal
npm install @krizaka/orazaka-client

One client of Orazaka's edge for every Krizaka TypeScript product, instead of one copy per product (Yomizaka, Orochia, soon Akinaza): start a Studio run, read its status and its outputs, wait for it. The base URL, the key and the clock are parameters — this package reads no environment and no wall clock.

import { createOrazakaClient, outputOf } from "@krizaka/orazaka-client";

const orazaka = createOrazakaClient({ baseUrl: "https://api.orazaka.com", apiKey: env.AI_API_KEY, clock: { now: () => new Date() } });

const { run } = await orazaka.startRun("compliance-check", { document: text }, { idempotencyKey: `doc-${documentId}-v${version}` });
const done = await orazaka.waitForRun(run.id); // or poll `getRun` yourself
if (done.status === "SUCCEEDED") use(outputOf(done, "report"));
  • Safe to retry. startRun with an idempotencyKey answers the run already started for the same key and inputs (replayed: true) instead of paying for a second one; the same key for other inputs is ORAZAKA_KEY_REUSED.
  • Typed errors. Every failure is an OrazakaError with a stable code (ORAZAKA_KEY, ORAZAKA_CREDITS, ORAZAKA_LOCKED, ORAZAKA_INPUT, ORAZAKA_NOT_FOUND, ORAZAKA_BUSY with retryAfterSeconds, ORAZAKA_UNAVAILABLE, ORAZAKA_TIMEOUT, ORAZAKA_SHAPE, ORAZAKA_CIRCUIT_OPEN…) and the status a product answers its own caller with. A product translates the codes; none is a sentence. A failed run is not an error: waitForRun gives it back with its errorMessage.
  • A time limit and a circuit breaker, as options: timeoutMs (20 s by default) on every call; five failures in a row (no answer, timeout, 5xx) open the circuit for 30 s — it refuses at once, then lets one call probe. A refusal (401, 402, 404, 429…) is an answer and never opens it. circuit: false turns it off.
  • Contract-tested against the edge's answers kept as fixtures (test/fixtures): when the edge changes a shape, the fixture changes first.

Run events as a stream (Server-Sent Events, GET /api/v1/studios/runs/{id}/events) come in a later minor; waitForRun polls until then.

Exports

The 21 names the package exports, read from its types.

NameKindWhat it is
Circuittype
CircuitOptionstype
Clocktype
createCircuitfunctionA circuit breaker over a dependency that may be down: after failureThreshold failures in a row it refuses at once (no waiting on a timeout, no load on a st…
createOrazakaClientfunctionOrazaka's edge, for every TypeScript product: one client instead of one copy per product.
isTerminalfunctionThe run is over, green or not: nothing more will change.
ORAZAKA_CODEconstantThe stable codes of a refusal or a failure of Orazaka's edge — a product translates them; none is a sentence.
OrazakaClienttype
OrazakaClientOptionstype
OrazakaCodetype
OrazakaErrorclass
orazakaRefusalfunctionWhat the edge's status means for a product that answers its own caller: the status to send back and the code.
OrazakaRuntypeA run, as the edge answers it (GET /api/v1/studios/runs/\{id\}).
outputOffunctionThe value of one output, or null when the run did not produce it (yet).
parseInstallationsfunctionThe Studios an account installed: GET /api/v1/studios/installations.
parseRunfunctionReads a run from the edge's JSON; anything else is ORAZAKA_SHAPE.
RUN_STATUSconstantWhere a run sits (orazaka-studio RunStatus).
RunOutputtypeOne output of a run (orazaka-studio RunArtefactResponse): type is a rendering hint (TEXT, IMAGE, VIDEO…).
StartedRuntype
StartRunOptionstype
WaitOptionstype

Package

Version on npmNot on npm yet
LicenceApache-2.0
Node.js>=22
Dependenciesdate-fns ^4.4.0
Sourceorazaka-client

Changelog

0.1.0

Minor changes

  • New: @krizaka/orazaka-client, the one Orazaka client for the TypeScript products (#33). Start a Studio run (idempotency key), read its status and outputs, wait for it; typed errors with stable codes, a time limit and a circuit breaker as options; base URL, key and clock as parameters; a fixture-based contract test.

On this page