Python Example
Replace <APPBASE_ENDPOINT_WITH_V1>, <APPBASE_CONSOLE_ORIGIN>, and <APPBASE_CONSOLE_HOST> where used with values for the intended environment before running the examples.
Initialization and invocation examples for each feature of the Python Server SDK (agentbase package, snake_case) and the Console SDK (agentbase_console package). Coordinates follow the published agentbase-sdks v2.12.0 ZIP release (the 2.6.0 iteration has no verifiable installable artifacts; the gap is logged in changelogs/2.6.0.md); runtime requires Python 3.9+ with runtime dependencies requests and pydantic>=2,<3.
Retrieval and Installation (Offline Wheel)
Artifacts are not published to PyPI; install with pip after unpacking the release ZIP (on an intranet, use PIP_INDEX_URL to point to a private mirror for dependencies):
BUNDLE_DIR="$(mktemp -d)"
BASE_URL="https://code.alipay.com/obai/agentbase-sdks/releases/download/v2.12.0"
curl -fsSL -o "$BUNDLE_DIR/agentbase-python-sdk-2.12.0.zip" "$BASE_URL/agentbase-python-sdk-2.12.0.zip"
curl -fsSL -o "$BUNDLE_DIR/agentbase-console-python-sdk-2.12.0.zip" "$BASE_URL/agentbase-console-python-sdk-2.12.0.zip"
curl -fsSL -o "$BUNDLE_DIR/SHA256SUMS" "$BASE_URL/SHA256SUMS"
(cd "$BUNDLE_DIR" && sha256sum -c --ignore-missing SHA256SUMS)
unzip "$BUNDLE_DIR/agentbase-python-sdk-2.12.0.zip" -d "$BUNDLE_DIR"
unzip "$BUNDLE_DIR/agentbase-console-python-sdk-2.12.0.zip" -d "$BUNDLE_DIR"
(cd "$BUNDLE_DIR/agentbase-python-sdk-2.12.0" && sha256sum -c SHA256SUMS)
(cd "$BUNDLE_DIR/agentbase-console-python-sdk-2.12.0" && sha256sum -c SHA256SUMS)
pip install "$BUNDLE_DIR/agentbase-python-sdk-2.12.0/agentbase_python_sdk-2.12.0-py3-none-any.whl"
pip install "$BUNDLE_DIR/agentbase-console-python-sdk-2.12.0/agentbase_console_python_sdk-2.12.0-py3-none-any.whl"Do not install the open-source appwrite official package as a stand-in for the Agentbase Python SDK — it lacks Agentbase extension surfaces such as TablesDB and Knowledge Bases.
Server SDK initialization
The agentbase package's __init__ is empty; all symbols are imported per module:
The Python Server SDK 2.12.0 default transport may forward the project API key on redirects. See the Python REST request example for a request that rejects redirects.
ClientOther configuration (all chained, returning Client): set_organization(value) (required for organization-level queries), set_jwt(value) / set_session(value) (only for controlled flows where the endpoint explicitly requires user identity; not a general substitute for an API Key), set_self_signed(status) (self-signed TLS environments), add_header(key, value).
Console SDK initialization
The Console login response body does not contain the session secret (it is only in the a_session_console cookie); first log in via raw HTTP to get the cookie, then attach it to the Console SDK client:
import re
import requests
from agentbase_console.client import Client as ConsoleClient
resp = requests.post(
'<APPBASE_ENDPOINT_WITH_V1>/account/sessions/email',
headers={'X-Appwrite-Project': 'console', 'Content-Type': 'application/json'},
json={'email': CONSOLE_EMAIL, 'password': CONSOLE_PASSWORD},
allow_redirects=False,
timeout=10,
)
if resp.status_code != 201:
raise RuntimeError(f'Console login failed: HTTP {resp.status_code}')
secret = re.search(r'a_session_console=([^;]+)', resp.headers['set-cookie']).group(1)
console_client = (
ConsoleClient()
.set_endpoint('<APPBASE_ENDPOINT_WITH_V1>')
.set_project('console')
)
console_client.add_header('origin', '<APPBASE_CONSOLE_ORIGIN>')
console_client.add_header('x-forwarded-host', '<APPBASE_CONSOLE_HOST>')
console_client.add_header('Cookie', f'a_session_console={secret}')The Console service surface (agentbase_console.services) includes account, teams, projects, users, proxy, migrations, etc.; method names are snake_case like the Server package. The Console package and Server package can coexist in the same environment.
TablesDB (Databases, Tables, Rows, Queries)
See the database API for database and table creation, writes, and queries.
Key points: columns / indexes take lists of dicts (generators are validated as DatabaseColumnDefinition / DatabaseIndexDefinition); for column/index type, follow the feature documentation Databases; the incremental column interfaces mostly return 202 asynchronous tasks; update_rows / delete_rows without queries act on the entire table, so always add a Query filter.
DocumentsDB and transactions
DocumentsDB is the document semantic surface of TablesDB (create_collection / create_document / list_documents…):
Create a transaction, submit its operations, and commit after checking the result. Review the transaction state before rolling back a failed operation. See the database API.
Users, teams, and storage
See the Users, Teams, and Storage APIs.
Service methods return pydantic models synchronously: access by field name (such as user.id); the model_type parameter only types the business data payload of documents / rows. The response body of a server-created user session contains no secret (only in the a_session_<projectId> cookie); to get a user-context client, read that cookie and then Client().set_session(secret).
Memory / Knowledge Bases / gateway and observability
Themed capabilities (Memory, Knowledge Bases, LLM Gateway, AI Gateway, Observability, Moderation, Messaging, Sites, etc.) each have a corresponding module under agentbase.services, with unified construction via Xxx(client); the method surface is isomorphic to the Node SDK (snake_case), and Python has completed the Knowledge Bases invocation surface since 15.4.0. For parameters and return structures, see each feature's documentation (agent workbench, memory, knowledge base, LLM and AI Gateway, observability, etc.); for JavaScript equivalents, see the corresponding sections of javascript.md; per-field Python signatures follow the agentbase.services module source code.
Error Handling
Check the HTTP status and response type when handling REST errors.