# TypeScript Client

> Install heyarchie from npm, name your region, and call Archie from Node, the browser or an edge runtime: messages, skills, files, typed errors and idempotency.

heyarchie is the TypeScript client for Archie. It needs Node 20 or newer, or any modern runtime with a global fetch: browsers, Deno, Cloudflare Workers and edge functions. It has no dependencies.

Install

## Install the Package

The Python SDK and the archie command line ship under the same name, with the same client shape.

bash

```
npm install heyarchie
# or
pnpm add heyarchie
# or
bun add heyarchie
```

Install

## The Pre-Release Channel

Pre-release builds come from staging and are aimed at the staging API. They live on the next dist-tag; npm install heyarchie always resolves latest and never gives you a pre-release.

bash

```
npm install heyarchie@next
```

Quick start

## Ask Archie a Question

Pass your key, your region and your workspace, or set ARCHIE_API_KEY, ARCHIE_API_URL and ARCHIE_WORKSPACE_ID. A key that reaches several workspaces must name one.

typescript

```
import { Archie } from "heyarchie";

const archie = new Archie({
  apiKey: "sk_...",
  // Archie serves one host per region: us, uk, au or ca. Or set ARCHIE_API_URL.
  baseURL: "https://uk.heyarchie.com",
  // Or set ARCHIE_WORKSPACE_ID in the environment.
  workspaceId: "ws_...",
});
// Or set ARCHIE_API_KEY in the environment.

const reply = await archie.messages.create({
  query: "What does ASC 710-10-25-2 require for vacation accrual?",
});
console.log(reply.output.answer);
for (const cite of reply.output.citations ?? []) {
  console.log(cite.standard, cite.section);
}
```

Skills

## Call Any Skill by Name

archie.skills reaches every skill your workspace exposes. List the live catalogue, then invoke a skill by its slug. archie.messages.create is a short form of the most-used skill, ask_archie.

typescript

```
const catalog = await archie.skills.list();
for (const s of catalog.data) {
  console.log(s.slug, "—", s.description);
}

const reply = await archie.skills.invoke("research_standards", {
  topic: "lease accounting",
  standard_references: ["AASB 16"],
  compare_standard_b: "FRS 102",
});
```

Files

## Upload a File, Then Analyse It

filename defaults to a File's own name. Each skill also has a typed method under archie.skills.generated.

typescript

```
const up = await archie.files.upload(new Blob([bytes]), "contract.pdf");
await archie.skills.generated.analyseDocument({ file_id: up.file_id });
```

Configuration

## Every Option

apiVersion pins the API revision. timeoutMs applies to each request. fetch replaces the global fetch, for tests and edge runtimes.

typescript

```
new Archie({
  apiKey: "sk_...",                       // or ARCHIE_API_KEY
  baseURL: "https://uk.heyarchie.com",    // REQUIRED, or one of the next three
  environment: "uk",                      // or ARCHIE_ENVIRONMENT — picks a region by name
  workspaceId: "ws_...",                  // or ARCHIE_WORKSPACE_ID
  apiVersion: "2026-04-24",               // pin the API revision
  timeoutMs: 920_000,                      // per-request
  fetch: customFetch,                     // for tests, edge runtimes
});
```

Which host

## How the Client Finds Its Host, Highest First

baseURL

option

A URL, such as https://uk.heyarchie.com.

environment

option

A region by name, such as "uk".

ARCHIE_API_URL

environment variable

A URL. The Python SDK and the archie command line read it too.

ARCHIE_ENVIRONMENT

environment variable

A region by name.

There is no default host

With none of them, the client throws; nothing is sent. Archie serves one hostname per region, so a default would be a wrong answer nobody is asked to confirm, and your data would go with it. Passing baseURL together with environment is a conflict and throws too.

Regions

## The Names Environment Takes

uk, us, au, ca

the four regions

Each is https://<name>.heyarchie.com.

staging

pre-release testing

https://gcp.staging.heyarchie.com, for the pre-release channel.

Anything else

refused

A name that is not in the table, or a row that is not live, throws and says why. Nothing is sent.

Workspace

Every call names a workspace in X-Workspace-ID, and the server refuses a call that does not. workspaceId resolves from the option, then ARCHIE_WORKSPACE_ID, then the one workspace your key belongs to, looked up once on the first call. If it belongs to several and you named none, the first call throws an Error listing their ids.

Errors

## Handle Errors by Type

The client throws typed errors decoded from the error body every refusal shares, each with its request id. It retries a 429 once by itself when Retry-After is 60 seconds or less.

typescript

```
import { ArchieRateLimitError, ArchieError } from "heyarchie";

try {
  await archie.skills.invoke("ask_archie", { query: "..." });
} catch (err) {
  if (err instanceof ArchieRateLimitError) {
    const wait = err.detail.retry_after_seconds ?? 60;
    console.log(`backing off ${wait}s`);
  } else if (err instanceof ArchieError) {
    console.error(err.detail.code, err.detail.message, err.requestId);
  } else {
    throw err;
  }
}
```

Idempotency

## Send a Call Safely Twice

Pass idempotencyKey on any invoke call. A replay within 24 hours returns the original response.

typescript

```
await archie.skills.invoke(
  "record_journal_entry",
  {
    client_id: "client_...",
    entries: [
      { account_code: "1000", debit: 100, credit: 0 },
      { account_code: "2000", debit: 0, credit: 100 },
    ],
    entry_date: "2026-04-25",
  },
  { idempotencyKey: "uniq-2026-04-25-q1-bas-001" },
);
```

Edge runtimes

Cloudflare Workers, Vercel Edge and Deno Deploy work as they are. The client relies only on fetch, URL, AbortController and setTimeout, which every standard runtime provides.

Next

### SDKs

Both clients side by side.

### Python SDK

The same client shape, with the archie command line.

### Error Handling

The error body every refusal shares.

### Authentication

Keys, and how a call proves who it is.

On this page

[Install the Package](https://heyarchie.com/en-gb/developers/sdk/typescript/#s-install)[The Pre-Release Channel](https://heyarchie.com/en-gb/developers/sdk/typescript/#s-install-2)[Ask Archie a Question](https://heyarchie.com/en-gb/developers/sdk/typescript/#s-quick-start)[Call Any Skill by Name](https://heyarchie.com/en-gb/developers/sdk/typescript/#s-skills)[Upload a File, Then Analyse It](https://heyarchie.com/en-gb/developers/sdk/typescript/#s-files)[Every Option](https://heyarchie.com/en-gb/developers/sdk/typescript/#s-configuration)[How the Client Finds Its Host, Highest First](https://heyarchie.com/en-gb/developers/sdk/typescript/#s-which-host)[The Names Environment Takes](https://heyarchie.com/en-gb/developers/sdk/typescript/#s-regions)[Handle Errors by Type](https://heyarchie.com/en-gb/developers/sdk/typescript/#s-errors)[Send a Call Safely Twice](https://heyarchie.com/en-gb/developers/sdk/typescript/#s-idempotency)
