- Source: github.com/krun-ai/krun-typescript
- npm package:
@krun-ai/sdk
Install
fetch).
Multimodal inputs,
multi questions and
assets require @krun-ai/sdk 0.3.0 or later, which also sets the default timeout to 180
seconds. With an earlier version, use decide(), feedback() and models() for text, and call the
HTTP API for assets.Quickstart
questions is written inline, TypeScript infers the ids: result.answers.department autocompletes, and
answer.choice is typed as "shipping" | "returns" | "billing" | null. Fields are camelCase (requestId,
abstentionStatus, inputTokens, taskType). Your question ids and option ids are never renamed.
Decision primitives
noul and score questions work the same way, with answers typed by their question:
Multimodal inputs and multi
Requires@krun-ai/sdk 0.3.0 or later. Upload media with client.assets.create() and reference it by assetId in a
list of content parts:
Feedback and models
Timeouts and retries
timeout: 180_000 yourself. The retry policy is the
same as the Python SDK: decide() and models() retry once after connection errors and
502, 503 or 504; feedback(), assets.create() and assets.delete() are never retried. See
Timeouts and cold starts.
Like the Python SDK, the TypeScript SDK is for server-side code. Never use a Krun API key in browser code. See Authentication.
Use the HTTP API directly
Without the SDK, call the API withfetch: