Skip to main content

Developer quickstart — Python & TypeScript SDKs

Everything you can do in the app, you can do from your own code. Velerian ships official, fully typed client SDKs for the governed-run + evidence APIs in Python and TypeScript, so you don't hand-roll auth, pagination, and error handling.

Each SDK bakes in the three things every integration repeats:

  • Auth — your API key is attached as a Bearer token on every request.
  • Pagination — iterators/generators walk the API's limit/offset pages for you.
  • Error handling — every non-2xx response maps to a typed exception, with first-class 429 / Retry-After handling and optional automatic backoff.
LanguagePackageRuntime
Pythonvelerian-sdkPython 3.10+ (only dependency: httpx)
TypeScript@velerian/sdkNode 18+ (uses the global fetch)

1. Install

Python

pip install velerian-sdk

TypeScript

npm install @velerian/sdk
Both packages are published — pip install velerian-sdk (PyPI) and npm install @velerian/sdk (npm) above are the install path. To build from source instead, use pip install ./sdks/python for Python, or cd sdks/typescript && npm install && npm run build for TypeScript.

2. Authenticate

Every request authenticates with an API key, sent as Authorization: Bearer <key>. A workspace administrator creates a key from an interactive session via the API-keys endpoint (POST /api/v2/api-keys); the key looks like vk_live_... and is shown exactly once. A key carries scopes — for the quickstart below you'll want runs:write (to invoke a pack) and evidence:read (to fetch its evidence).

Handing access to an outside system or partner? Instead of a workspace-wide key, you can expose a single agent and get a key that works only for that agent — see Expose an agent and call it from outside.

Read the key from the environment — never hard-code it or commit it. The examples read VELERIAN_API_KEY (and an optional VELERIAN_BASE_URL, which defaults to https://app.velerian.ai).

A missing, invalid, or expired key raises an auth error (HTTP 401); a key lacking a required scope raises a forbidden error (HTTP 403).

3. Your first authenticated call

The fastest first call needs nothing but your key: invoke a workspace workflow by its slug — nothing to create or deploy. The slug is the workflow identifier in your Client Workspace; replace your-pack-slug below with one your workspace can access.

Python

import os
from velerian_sdk import VelerianClient

with VelerianClient(
    api_key=os.environ["VELERIAN_API_KEY"],            # vk_live_...
    base_url=os.environ.get("VELERIAN_BASE_URL", "https://app.velerian.ai"),
) as client:
    run = client.invoke_network(
        "your-pack-slug",
        prompt_text="Summarize the attached filing.",
    )
    print("run:", run["run_id"], "->", run["run_url"])
    print("governed:", run["governance_pass"])
    print(run["output_text"])

TypeScript

import { VelerianClient } from "@velerian/sdk";

const client = new VelerianClient({
  apiKey: process.env.VELERIAN_API_KEY!,                 // vk_live_...
  baseUrl: process.env.VELERIAN_BASE_URL ?? "https://app.velerian.ai",
});

const run = await client.invokeNetwork("your-pack-slug", {
  prompt_text: "Summarize the attached filing.",
});
console.log(run.run_id, run.run_url);
console.log(run.governance_pass, run.output_text);

Each run returns the work product and a governance verdict — the same governed-run model as in the app.

It also returns the run's own identity, so you never have to go looking for the run you just started:

FieldWhat it is
run_idThe run's id — pass it straight to GET /api/v2/pack-runs/{run_id} to re-read the run, .../revise to run it again with corrections, .../share to mint a share link, or the evidence export routes
run_urlThe run's page in the app — the link to open in a browser, paste into a ticket, or send to a reviewer

Each run returns the work product and a governance verdict — the same governed-run model you see in the app (see Governance & evidence). Each completed run counts as one governed run; you are billed under your agreement, not per run (see Agreement & billing).

Listing and pagination

List endpoints use limit/offset, and both SDKs expose a single-page accessor plus an auto-iterating generator that walks every page for you.

Python

# One page:
page = client.list_audit_log(action="pack_run.share_link_minted", limit=50)

# Every entry, transparently across pages:
for entry in client.iter_audit_log(action="pack_run.share_link_minted"):
    print(entry["created_at"], entry["action"])

TypeScript

// One page:
const page = await client.listAuditLog({ action: "pack_run.share_link_minted", limit: 50 });

// Every entry, transparently across pages:
for await (const entry of client.iterAuditLog({ action: "pack_run.share_link_minted" })) {
  console.log(entry.created_at, entry.action);
}

Handling errors

Every non-2xx response becomes a typed error you can catch by kind — for example a 429 rate-limit error exposes the retry delay. By default the client also retries 429 and 5xx up to three times, honoring the server's Retry-After and using full-jitter exponential backoff otherwise.

Python

from velerian_sdk import VelerianForbiddenError, VelerianRateLimitError

try:
    client.invoke_network("your-pack-slug", prompt_text="...")
except VelerianForbiddenError as e:
    print("missing scope:", e.detail)
except VelerianRateLimitError as e:
    print("retry after", e.retry_after, "seconds")

TypeScript

import { VelerianForbiddenError, VelerianRateLimitError } from "@velerian/sdk";

try {
  await client.invokeNetwork("your-pack-slug", { prompt_text: "..." });
} catch (err) {
  if (err instanceof VelerianForbiddenError) console.error("missing scope:", err.detail);
  else if (err instanceof VelerianRateLimitError) console.error("retry after", err.retryAfter);
  else throw err;
}

Fuller documentation

For the full method surface, pagination overrides, typed-error tables, retry tuning, and raw-request examples, read the package documentation:

Both SDKs target the /api/v2 API and follow the published OpenAPI 3.1 contract. TypeScript types are generated from that contract; the Python client is maintained and tested against it. Use the API reference for the deployed contract and the package documentation for your installed SDK version.