TypeScript Client
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 the Package
The Python SDK and the archie command line ship under the same name, with the same client shape.
npm install heyarchie # or pnpm add heyarchie # or bun add heyarchie
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.
npm install heyarchie@next
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.
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);
}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.
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",
});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.
const up = await archie.files.upload(new Blob([bytes]), "contract.pdf");
await archie.skills.generated.analyseDocument({ file_id: up.file_id });Every Option
apiVersion pins the API revision. timeoutMs applies to each request. fetch replaces the global fetch, for tests and edge runtimes.
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
});How the Client Finds Its Host, Highest First
A URL, such as https://uk.heyarchie.com.
A region by name, such as "uk".
A URL. The Python SDK and the archie command line read it too.
A region by name.
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.
The Names Environment Takes
Each is https://<name>.heyarchie.com.
https://gcp.staging.heyarchie.com, for the pre-release channel.
A name that is not in the table, or a row that is not live, throws and says why. Nothing is sent.
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.
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.
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;
}
}Send a Call Safely Twice
Pass idempotencyKey on any invoke call. A replay within 24 hours returns the original response.
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" },
);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.