Python SDK for Asgard Core API
Project description
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)
Project details
Release history Release notifications | RSS feed
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 asgard_sdk-0.1.0.tar.gz.
File metadata
- Download URL: asgard_sdk-0.1.0.tar.gz
- Upload date:
- Size: 52.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
523c2202e9a8296cf67bf93e50d9ce8d1fef89a09194cafa1f274c87013d7590
|
|
| MD5 |
f5279afb181cf5cdfc5747ed66b0f8e9
|
|
| BLAKE2b-256 |
77f8cb6d2bb715f1d763b88b1633cf2cbc09dab3ccdc543c88896adc9fd9caa7
|
Provenance
The following attestation bundles were made for asgard_sdk-0.1.0.tar.gz:
Publisher:
publish.yml on asgard-ai-platform/asgard-sdk-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
asgard_sdk-0.1.0.tar.gz -
Subject digest:
523c2202e9a8296cf67bf93e50d9ce8d1fef89a09194cafa1f274c87013d7590 - Sigstore transparency entry: 1467371396
- Sigstore integration time:
-
Permalink:
asgard-ai-platform/asgard-sdk-python@75d4b55bff4ddf67284b1a0b49c2527c750449c2 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/asgard-ai-platform
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@75d4b55bff4ddf67284b1a0b49c2527c750449c2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file asgard_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: asgard_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a8833352e8b25e8582d06d6047a6be16fd426ccd2b2d1f40f2eeedce5e4e9b6
|
|
| MD5 |
d73f5ee45b3d4d22b950d548c2c12a78
|
|
| BLAKE2b-256 |
2d6f674666a63960561fe11a913a020f668739caf7a3d7c034623ba9238939df
|
Provenance
The following attestation bundles were made for asgard_sdk-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on asgard-ai-platform/asgard-sdk-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
asgard_sdk-0.1.0-py3-none-any.whl -
Subject digest:
6a8833352e8b25e8582d06d6047a6be16fd426ccd2b2d1f40f2eeedce5e4e9b6 - Sigstore transparency entry: 1467371571
- Sigstore integration time:
-
Permalink:
asgard-ai-platform/asgard-sdk-python@75d4b55bff4ddf67284b1a0b49c2527c750449c2 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/asgard-ai-platform
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@75d4b55bff4ddf67284b1a0b49c2527c750449c2 -
Trigger Event:
push
-
Statement type: