Skip to main content

asgard-sdk-python

Python SDK for the Asgard Core API. Sync-first, with async extensibility in mind.

Installation

uv add asgard-sdk-python

Or for development:

uv sync --extra dev

Requirements

Python 3.11+

Quick Start

BotProviderClient

from asgard import BotProviderClient, GenericBotMessage

client = BotProviderClient(
    host="http://localhost:8080",
    namespace="my-ns",
    bot_provider_name="my-bot",
    api_key="secret",
)

# Send a message (REST)
message = GenericBotMessage(custom_channel_id="ch-1", custom_message_id="m-1", text="hello")
reply = client.send_message(message)
for m in reply.messages:
    print(m.text)

# Stream a message (SSE)
with client.stream(message) as stream:
    for event in stream:
        if event.event_type.value == "asgard.message.delta":
            print(event.fact.message_delta.text, end="", flush=True)

# Upload a blob
with open("image.png", "rb") as f:
    blobs = client.upload_blob(custom_channel_id="ch-1", file=f, filename="image.png", mime="image/png")

FunctionAgentClient

from asgard import FunctionAgentClient

client = FunctionAgentClient(
    host="http://localhost:8080",
    namespace="my-ns",
    bot_provider_name="my-agent",
    api_key="secret",
)

result = client.trigger_json({"key": "value"})

with open("data.csv", "rb") as f:
    result = client.trigger_form({"key": "value"}, file=f, filename="data.csv", mime="text/csv")

Environment Variables

Variable Description
EDGE_SERVER_HOST EdgeServer host URL
NAMESPACE Asgard namespace
BOT_PROVIDER_NAME Bot/agent name
BOT_PROVIDER_API_KEY API key

CLI

# Bot interactive REPL (SSE by default)
asgard-cli --host http://localhost:8080 --namespace default --bot my-bot --apikey secret

# Switch to REST transport
asgard-cli --host ... --namespace ... --bot ... --apikey ... --transport rest

# Using env vars
export EDGE_SERVER_HOST=http://localhost:8080
export NAMESPACE=default
export BOT_PROVIDER_NAME=my-bot
export BOT_PROVIDER_API_KEY=secret
asgard-cli

# Function agent — JSON trigger
asgard-cli --agent function --json-trigger \
  --trigger-payload '{"key": "value"}' \
  --host ... --namespace ... --bot ... --apikey ...

# Function agent — Form trigger
asgard-cli --agent function --form-trigger \
  --trigger-payload '{"key": "value"}' \
  --form-file ./data.csv --form-mime text/csv \
  --host ... --namespace ... --bot ... --apikey ...

Bot REPL commands

Command Description
/help Show help
/exit / /quit Exit
/transport sse|rest Switch transport
/debug on|off Toggle debug mode
/blob <path> [mime] Upload and attach a blob
/blobs Show attached blob IDs
/clear-blobs Clear attached blobs
/channel [id] Show or switch channel
/reset [text] Send RESET_CHANNEL action

Error Handling

from asgard import AsgardError, AsgardStreamError

try:
    reply = client.send_message(message)
except AsgardError as e:
    print(e.detail.message)  # human-readable error
    print(e.detail.code)     # error code

try:
    with client.stream(message) as stream:
        for event in stream:
            ...
except AsgardStreamError as e:
    print(e.detail.message)

Tool Call Consent

from asgard import GenericBotMessage, ToolCallConsentResponseItem, ToolCallConsentResult, PostBackAction

# After receiving a tool_call.consent event:
consent_items = [
    ToolCallConsentResponseItem(
        tool_call_id="tc-1",
        result=ToolCallConsentResult.ALLOW_ONCE,
    )
]

response = GenericBotMessage(
    custom_channel_id="ch-1",
    custom_message_id="m-2",
    action=PostBackAction.RESPONSE_TOOL_CALL_CONSENT,
    tool_call_consents=consent_items,
)
reply = client.send_message(response)

Metadata

Release files for asgard-sdk 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for asgard-sdk 0.1.0
File Size Uploaded
asgard_sdk-0.1.0.tar.gz 52.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for asgard-sdk 0.1.0
File Interpreter ABI Platform
asgard_sdk-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 66.9 kB

Release files / asgard_sdk-0.1.0.tar.gz

Download URL asgard_sdk-0.1.0.tar.gz
Size 52.5 kB
Tags Source
SHA-256 checksum
How to use checksums
523c2202e9a8296cf67bf93e50d9ce8d1fef89a09194cafa1f274c87013d7590
BLAKE2b-256 checksum
How to use checksums
77f8cb6d2bb715f1d763b88b1633cf2cbc09dab3ccdc543c88896adc9fd9caa7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 8, 2026.

Transparency log

Release files / asgard_sdk-0.1.0-py3-none-any.whl

Download URL asgard_sdk-0.1.0-py3-none-any.whl
Size 14.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6a8833352e8b25e8582d06d6047a6be16fd426ccd2b2d1f40f2eeedce5e4e9b6
BLAKE2b-256 checksum
How to use checksums
2d6f674666a63960561fe11a913a020f668739caf7a3d7c034623ba9238939df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 8, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page