# Python SDK

> Install heyarchie, name your region, and call Archie from Python: messages, skills, files and agent-framework tools, with typed errors.

One package, heyarchie, gives you the Python SDK (import heyarchie) and the archie command line. It needs Python 3.11 or newer.

Install

## Install the Package

As a library, install it into your project's virtualenv. As a command line, install it on its own with pipx or uv. On macOS a bare pip install can stop at externally-managed-environment, because Homebrew guards the system Python; pipx and uv manage a virtualenv for you and avoid it.

bash

```
pip install heyarchie

pipx install heyarchie     # brew install pipx first, if needed
# or, with uv:
uv tool install heyarchie
```

Install

## The Pre-Release Channel

Pre-release builds come from staging and are aimed at the staging API. --pre is required: they are published as pre-release versions so that a plain pip install heyarchie never picks one up by accident.

bash

```
pip install --pre heyarchie
```

Which host

## Name Your Region

There is no default host. Archie serves one hostname per region, so the client refuses to start until you name one; a default would quietly send your key and your data to whichever region it named. Name it by URL, or by region name with environment.

python

```
import heyarchie
from heyarchie.environments import api_url

archie = heyarchie.Archie(api_key="sk_...", base_url=api_url("uk"))
```

Which host

## How the Client Finds Its Host, Highest First

base_url

argument

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

environment

keyword argument

A region by name, such as "uk".

ARCHIE_API_URL

environment variable

A URL. The archie command line reads it too.

ARCHIE_ENVIRONMENT

environment variable

A region by name.

No host named

With none of them, the client raises ArchieConfigError rather than guessing. Giving both base_url and environment raises it as well.

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, raises and says why. Nothing is sent.

From the command line

## Sign in Once With the Archie Command

archie auth login saves the host it resolved to ~/.archie/credentials.toml, and every later command reuses it. Its order, highest first: --api-url, --environment, ARCHIE_API_URL, ARCHIE_ENVIRONMENT, then the saved profile.

bash

```
archie auth login --api-url https://<your-archie-host>
archie auth login --environment uk          # -> https://uk.heyarchie.com
archie auth login --environment staging     # -> https://gcp.staging.heyarchie.com

export ARCHIE_API_URL=https://<your-archie-host>
export ARCHIE_ENVIRONMENT=uk
```

Quick start

## Ask Archie a Question

Pass your key, your region and your workspace. A key that reaches several workspaces must name one, with workspace_id or ARCHIE_WORKSPACE_ID.

python

```
import heyarchie

archie = heyarchie.Archie(
    api_key="sk_...",
    base_url="https://uk.heyarchie.com",   # or export ARCHIE_API_URL
    workspace_id="ws_...",                 # or export ARCHIE_WORKSPACE_ID
)
message = archie.messages.create(
    "Summarise the BAS for Q1 2026",
    client_id="<client id>",
)
print(message.content)
if message.citations:
    print(message.citations[0].standard)
```

Async

## The Async Client

AsyncArchie takes the same arguments. Await the same methods.

python

```
import asyncio
import heyarchie

async def main():
    async with heyarchie.AsyncArchie(
        api_key="sk_...",
        base_url="https://uk.heyarchie.com",
    ) as archie:
        message = await archie.messages.create("Summarise BAS Q1 2026")
        print(message.content)

asyncio.run(main())
```

Workspace

## Name Your Workspace

The server refuses a signed-in request that names no workspace, so every call carries X-Workspace-ID. With neither workspace_id nor ARCHIE_WORKSPACE_ID, the client lists your workspaces once and uses the only one. With several, it raises ArchieConfigError naming them; it never guesses.

python

```
Archie(api_key=..., base_url=..., workspace_id="ws-1")   # or export ARCHIE_WORKSPACE_ID
```

Skills

## Documents, Journal Entries and Reports

Each of these is a skill, called as archie.skills.<name>(...). The call returns the server's reply as a dict, with the skill's result under output. To analyse a file, upload it first and pass the id it returns: a str is a path, and bytes take filename= so Archie can tell the type.

python

```
up = archie.files.upload("contract.pdf")
analysis = archie.skills.analyse_document(file_id=up.file_id, analysis_type="summarize")
pack = archie.skills.prepare_cfo_pack(client_id="<client id>", period="2026-06", output_format="pdf")
entry = archie.skills.record_journal_entry(
    client_id="<client id>",
    entries=[
        {"account_code": "1000", "debit": "100.00", "credit": "0"},
        {"account_code": "4000", "debit": "0", "credit": "100.00"},
    ],
    entry_date="2026-06-30",
)
print(analysis["output"], pack["output"], entry["output"])
```

Skills

## Search, Standards and Drafts

These are skills too. Each call returns the skill's reply as a dict.

python

```
found = archie.skills.search_knowledge(query="ASC 606 lease", sources=["standards"], jurisdiction="US")
research = archie.skills.research_standards(
    topic="revenue recognition",
    standard_references=["ASC 606"],
    jurisdiction="US",
    mode="research",
)
draft = archie.skills.prepare_communication(
    type="email",
    recipients=["alex@example.com"],
    subject="Q1 BAS",
    context="Remind about the BAS",
    tone="professional",
)
```

What else the client holds

Beside messages, skills and files, the client has conversations, triggers, and keys, which lists, creates, updates, rotates and revokes your API keys. Calls wait up to 920 seconds by default; pass timeout= in seconds to change it.

Errors

## Handle Errors by Type

A call that fails raises a typed error. Every one is an ArchieError carrying status and request_id; a rate limit carries retry_after, in seconds, from the Retry-After header.

python

```
import time
import heyarchie

try:
    message = archie.messages.create("Summarise the BAS for Q1 2026")
except heyarchie.ArchieRateLimitError as err:
    time.sleep(err.retry_after or 60)
except heyarchie.ArchieError as err:
    print(err.status, err.request_id)
```

Errors

## Which Error, for Which Answer

ArchieAuthError

401

The key is missing, wrong or revoked.

ArchiePermissionError

403

The key may not do this, or no workspace was named.

ArchieNotFoundError

404

Nothing is there.

ArchieRateLimitError

429

Too many calls. Wait retry_after seconds.

Errors

## And the Rest

ArchieValidationError

400, 422

The request was refused as written.

ArchieConflictError

409

It conflicts with the current state. ArchieIdempotencyError is the kind raised for an idempotency key still in use.

ArchieGoneError

410

It has expired or been retired.

ArchieAPIError

5xx

A failure on our side. Retry later.

Before a call is sent

ArchieConfigError means the client could not be set up: no host, both a host and a region, or no workspace it can choose. ArchieTimeoutError means a call waited longer than its timeout.

Agent frameworks

## Use Archie Skills as Agent Tools

The client turns Archie's skills into native tools for LangGraph and LangChain, or the OpenAI Agents SDK. The tools call Archie with your key, name your workspace, and raise the same typed errors. scope= keeps only the skills whose permission matches. heyarchie.adapters.as_langchain_tools does the same for LangChain on its own.

python

```
import heyarchie

archie = heyarchie.Archie(api_key="sk_...", base_url="https://uk.heyarchie.com")

tools = archie.skills.as_langgraph_tools(scope="topics:read")  # LangGraph and LangChain
tools = archie.skills.as_openai_tools(scope="topics:read")     # OpenAI Agents SDK
```

No streaming

Archie answers a skill or a message with one complete reply, so there is no streaming call. messages.create(..., stream=True) raises ValueError.

No sandbox

sandbox=True raises ArchieConfigError: there is no sandbox. Isolation in Archie is per workspace. Create a throwaway workspace, issue a key scoped to it, and point the SDK at that key.

Next

### SDKs

Both clients side by side.

### TypeScript Client

The same client shape for Node and edge runtimes.

### CLI

The archie command line, in the same package.

### Error Handling

The error body every refusal shares.

On this page

[Install the Package](https://heyarchie.com/en-gb/developers/sdk/python/#s-install)[The Pre-Release Channel](https://heyarchie.com/en-gb/developers/sdk/python/#s-install-2)[Name Your Region](https://heyarchie.com/en-gb/developers/sdk/python/#s-which-host)[How the Client Finds Its Host, Highest First](https://heyarchie.com/en-gb/developers/sdk/python/#s-which-host-2)[The Names Environment Takes](https://heyarchie.com/en-gb/developers/sdk/python/#s-regions)[Sign in Once With the Archie Command](https://heyarchie.com/en-gb/developers/sdk/python/#s-from-the-command-line)[Ask Archie a Question](https://heyarchie.com/en-gb/developers/sdk/python/#s-quick-start)[The Async Client](https://heyarchie.com/en-gb/developers/sdk/python/#s-async)[Name Your Workspace](https://heyarchie.com/en-gb/developers/sdk/python/#s-workspace)[Documents, Journal Entries and Reports](https://heyarchie.com/en-gb/developers/sdk/python/#s-skills)[Search, Standards and Drafts](https://heyarchie.com/en-gb/developers/sdk/python/#s-skills-2)[Handle Errors by Type](https://heyarchie.com/en-gb/developers/sdk/python/#s-errors)[Which Error, for Which Answer](https://heyarchie.com/en-gb/developers/sdk/python/#s-errors-2)[And the Rest](https://heyarchie.com/en-gb/developers/sdk/python/#s-errors-2-2)[Use Archie Skills as Agent Tools](https://heyarchie.com/en-gb/developers/sdk/python/#s-agent-frameworks)
