Python SDK for the ArchAstro Platform API
Project description
ArchAstro Python SDK
Python SDK for the ArchAstro Platform API and ArchAgents runtime APIs.
uv add archastro-sdk
# or
pip install archastro-sdk
The clients default to the production API gateway, https://platform.archastro.ai.
Set ARCHASTRO_PLATFORM_BASE_URL only when targeting local development,
staging, or another non-production environment.
Getting Started
Choose the auth path that matches how your Python process should run.
ArchAgents Org Bot or Worker
Use this path for ArchAgents bots, background workers, cron jobs, ingestion jobs, and integrations that should act as an org-owned system user. Your Python process only needs a system-user access token:
export ARCHASTRO_ACCESS_TOKEN=sat_...
Create that token with archagent while logged in as an org admin. Replace
user@company.com with your ArchAgents login email. The setup is grouped as
one shell block so GitHub's copy button copies the full sequence:
archagent auth login user@company.com
export ARCHASTRO_ORG_ID="$(
archagent describe me --json |
jq -er '.session.org'
)"
export ARCHASTRO_SYSTEM_USER_ID="$(
archagent --json create user \
--system-user \
--name "Python SDK Bot" \
--org "$ARCHASTRO_ORG_ID" \
--org-role member |
jq -r '.id'
)"
export ARCHASTRO_ACCESS_TOKEN="$(
archagent --json create usertoken \
--user "$ARCHASTRO_SYSTEM_USER_ID" \
--name "python-sdk-service" |
jq -r '.token'
)"
Use the sync client for scripts and CLIs:
import os
from archastro.platform import PlatformClient
with PlatformClient(access_token=os.environ["ARCHASTRO_ACCESS_TOKEN"]) as client:
user = client.users.me()
print(user["id"], user.get("is_system_user"))
Use the async client inside async services or workers:
import asyncio
import os
from archastro.platform import AsyncPlatformClient
async def main() -> None:
async with AsyncPlatformClient(
access_token=os.environ["ARCHASTRO_ACCESS_TOKEN"],
) as client:
user = await client.users.me()
print(user["id"], user.get("is_system_user"))
asyncio.run(main())
See examples/org_system_user_token for the
complete system-user walkthrough.
Developer App Auth
Use this path when you already have a publishable API key and a user access token from a developer app login flow.
export ARCHASTRO_API_KEY=pk_...
export ARCHASTRO_ACCESS_TOKEN=sat_...
import os
from archastro.platform import PlatformClient
client = PlatformClient.with_token(
os.environ["ARCHASTRO_API_KEY"],
os.environ["ARCHASTRO_ACCESS_TOKEN"],
)
with client:
teams = client.teams.list()
Async setup uses the same factory:
import asyncio
import os
from archastro.platform import AsyncPlatformClient
async def main() -> None:
async with AsyncPlatformClient.with_token(
os.environ["ARCHASTRO_API_KEY"],
os.environ["ARCHASTRO_ACCESS_TOKEN"],
) as client:
teams = await client.teams.list()
print(teams)
asyncio.run(main())
Examples
examples/org_system_user_token— run the SDK as an ArchAgents org-owned system user.examples/create_agent_cli— wrap the sync SDK in a small CLI that creates an agent.examples/thread_chat_tui— chat in an existing thread from a terminal UI using the async websocket helpers.
Packages
All public code lives under the single top-level archastro package:
archastro.platform— typed REST + channel SDK generated from the canonical OpenAPI spec atArchAstro/archastro-openapi. Pydantic models, async channel classes, auth helpers.archastro.phx_channel— the hand-written Phoenix Channels client the generated channel classes run on top of. WebSocket transport, join / reply / push / leave, heartbeat, reconnect, and aHarnessServiceClientfor driving the@archastro/channel-harnessservice from Python tests.
Development
This repo contains:
- Python SDK (
src/archastro/) installed viauv - JS tooling (
package.json) — the channel-harness subprocess that powers the channel contract tests, plus the Prism mock server that backs the REST contract tests. Installed vianpm ci.
Setup
npm ci --ignore-scripts # channel-harness + prism (for contract tests)
uv sync --locked --all-extras
Running tests
# Unit tests only (no external services needed)
uv run pytest tests/test_http_client.py src/archastro/phx_channel/tests/test_unit.py
# Example smoke/unit tests
uv run pytest tests/examples
# REST contract tests (spawns Prism mock server)
uv run pytest tests/contract
# REST + channel contract tests (also spawns channel-harness subprocess)
ARCHASTRO_RUN_CHANNEL_CONTRACT_TESTS=1 uv run pytest tests/contract
Regenerating the SDK
The typed SDK — src/archastro/platform/ and tests/contract/ — is
regenerated from the canonical OpenAPI spec by
@archastro/sdk-generator.
Don't hand-edit files with the auto-generated by @archastro/sdk-generator
header; they'll be overwritten.
./scripts/regenerate_sdk.sh
The script fetches the spec from ArchAstro/archastro-openapi@main and
runs the generator locked in package-lock.json. Knobs:
ARCHASTRO_OPENAPI_REF=some-branch ./scripts/regenerate_sdk.sh— pull the spec from a non-default ref (useful when a spec change is on a branch awaiting merge).
After regenerating, review the diff, run the full test suite, and commit.
Release
# bump version in pyproject.toml, then:
uv sync --locked --all-extras
uv build --no-build-isolation
uv publish
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file archastro_sdk-0.3.0.tar.gz.
File metadata
- Download URL: archastro_sdk-0.3.0.tar.gz
- Upload date:
- Size: 285.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d89096c8433fb3dd061d3dc7ad671d483cb160c2309a78820c648bfa3caec99
|
|
| MD5 |
3d6eabf6a0ba77b5184475a2a174c96e
|
|
| BLAKE2b-256 |
2fa0eed84e21e58b31f330ef24933673075fbfa5b8ec3fa6e604557a215c72be
|
Provenance
The following attestation bundles were made for archastro_sdk-0.3.0.tar.gz:
Publisher:
publish.yml on ArchAstro/archastro-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
archastro_sdk-0.3.0.tar.gz -
Subject digest:
2d89096c8433fb3dd061d3dc7ad671d483cb160c2309a78820c648bfa3caec99 - Sigstore transparency entry: 1806498216
- Sigstore integration time:
-
Permalink:
ArchAstro/archastro-python@cc7a5c7c0a5c24f2e9686bbb3d53640feb350b57 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/ArchAstro
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@cc7a5c7c0a5c24f2e9686bbb3d53640feb350b57 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file archastro_sdk-0.3.0-py3-none-any.whl.
File metadata
- Download URL: archastro_sdk-0.3.0-py3-none-any.whl
- Upload date:
- Size: 106.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bdc1a145bf01242b7b013e8dd25b0827d9cf0056fce560942edf16eac761ac23
|
|
| MD5 |
7ecb80b5950410f1046751386405ddf6
|
|
| BLAKE2b-256 |
c69ed2306a3b66a111830467689e07c10f03943a98ae30a44de13e6ae7c72cd5
|
Provenance
The following attestation bundles were made for archastro_sdk-0.3.0-py3-none-any.whl:
Publisher:
publish.yml on ArchAstro/archastro-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
archastro_sdk-0.3.0-py3-none-any.whl -
Subject digest:
bdc1a145bf01242b7b013e8dd25b0827d9cf0056fce560942edf16eac761ac23 - Sigstore transparency entry: 1806498236
- Sigstore integration time:
-
Permalink:
ArchAstro/archastro-python@cc7a5c7c0a5c24f2e9686bbb3d53640feb350b57 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/ArchAstro
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@cc7a5c7c0a5c24f2e9686bbb3d53640feb350b57 -
Trigger Event:
workflow_dispatch
-
Statement type: