Python SDK for Dirigex self-service APIs
Project description
Dirigex Python SDK (v0.1.0)
Python SDK for Dirigex self-service endpoints:
POST /self/register/bootstrapGET /self/mePOST /self/session/refresh-contextGET /self/tenant/catalog/agentsPOST /self/tenant/agents/{agentId}/invokePOST /self/tenant/agents/registerGET /self/tenant/usageGET /self/tenant/audit-eventsPOST /self/tenant/exportPOST /self/tenant/webhooksGET /self/tenant/webhooksPOST /self/tenant/webhooks/{subscriptionId}/revoke
Install
pip install dirigex-sdk
For reproducible production installs:
pip install "dirigex-sdk==0.1.0"
During local repository development, use an editable workspace install:
pip install -e packages/dirigex-sdk-python
Sync quickstart
from dirigex_sdk import create_dirigex_client
client = create_dirigex_client(
base_url="https://api.dirigex.ai",
get_token=lambda: "<bearer-jwt>",
)
bootstrap = client.self.bootstrap()
me = client.self.me()
refreshed = client.self.refresh_context()
Async quickstart
from dirigex_sdk import create_async_dirigex_client
async def run() -> None:
async with create_async_dirigex_client(
base_url="https://api.dirigex.ai",
get_token=lambda: "<bearer-jwt>",
) as client:
bootstrap = await client.self.bootstrap()
me = await client.self.me()
refreshed = await client.self.refresh_context()
Authentication integration
get_token is caller-managed and invoked per request.
- Sync client:
get_token: Callable[[], str] - Async client:
get_token: Callable[[], str | Awaitable[str]]
Common pitfall: stale cached tokens. If you see invalid_token, refresh in your token provider.
If get_token returns an empty or whitespace-only token, the SDK throws
auth_token_unavailable before sending any network request.
Error handling
from dirigex_sdk import (
DirigexError,
RateLimitedError,
InvalidTokenError,
TenantSuspendedError,
ConsumerEmailDomainBlockedError,
)
try:
client.self.bootstrap()
except RateLimitedError as error:
# error.retry_after_seconds may be populated from Retry-After
pass
except InvalidTokenError:
pass
except TenantSuspendedError:
pass
except ConsumerEmailDomainBlockedError:
pass
except DirigexError as error:
print(error.code, error.raw_server_code, error.status)
Server-emitted codes (14)
authentication_requiredinvalid_tokenself_service_auth_unavailableemail_requiredinvalid_email_domaintenant_not_foundtenant_membership_not_foundtenant_suspendeduser_disableduser_not_activeemail_not_verifiedconsumer_email_domain_blockedtenant_create_race_unresolvedrate_limited
SDK-emitted codes
network_errornon_json_errormalformed_responseunknown_server_error
raw_server_code is always preserved for server-emitted errors. For SDK-emitted errors it is an empty string.
Retry behavior
Default retry config:
{
"on_rate_limited": True,
"on_service_unavailable": False,
"max_attempts": 3,
"respect_retry_after": True,
"max_retry_after_seconds": 60, # optional; default 60; cap on Retry-After waits
}
429 rate_limited: retries by default.503 self_service_auth_unavailable: retry is opt-in.Retry-Aftersupports both numeric seconds and HTTP-date formats.Retry-Afterwaits are capped viamax_retry_after_seconds(default 60) so a misconfigured or hostile server cannot stall the client indefinitely. The cap only affects internal retry timing —error.retry_after_secondsexposed to callers preserves the original uncapped value from the server header for triage.
Transport security
base_url must use https:// for any non-localhost host. The SDK rejects
plaintext-HTTP URLs at construction time (ValueError) to prevent bearer
tokens from being transmitted unencrypted. http://localhost,
http://127.0.0.1, and http://[::1] are accepted for local development.
Type-shape contract
Response objects preserve wire-format field names (camelCase) to match the API contract:
- Bootstrap:
tenantId,role,onboardingState - Me/refresh:
userSub,email,tenantId,roles,capabilities
License
MIT — see LICENSE.
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 dirigex_sdk-0.1.0.tar.gz.
File metadata
- Download URL: dirigex_sdk-0.1.0.tar.gz
- Upload date:
- Size: 27.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
82773de54163ec9b4fcab04685252909d9c349c556d276c688ef5d5c97b8c717
|
|
| MD5 |
2c132248b68a278745b2b08650ff6976
|
|
| BLAKE2b-256 |
b143ddc3da4d20e0e56929a958e46b092a58e61ee1c47f036b27289aeab7c343
|
Provenance
The following attestation bundles were made for dirigex_sdk-0.1.0.tar.gz:
Publisher:
sdk-publish-py.yml on DirigexAI/Dirigex
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dirigex_sdk-0.1.0.tar.gz -
Subject digest:
82773de54163ec9b4fcab04685252909d9c349c556d276c688ef5d5c97b8c717 - Sigstore transparency entry: 2025698942
- Sigstore integration time:
-
Permalink:
DirigexAI/Dirigex@0b1fac6f2002ab574cd32f79e4e14628d3a3df4a -
Branch / Tag:
refs/heads/codex/python-sdk-publish-fix - Owner: https://github.com/DirigexAI
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
sdk-publish-py.yml@0b1fac6f2002ab574cd32f79e4e14628d3a3df4a -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file dirigex_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: dirigex_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 22.0 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 |
c31d596d041b014f9d59fbc5e0300ae942e041098c56687611c67f29d632e0f6
|
|
| MD5 |
f48016a719a667bd845c765b29cfa6ee
|
|
| BLAKE2b-256 |
c47422a85fd28d8431eacf66dcbee800907ece2024c03025f1c490579042b4c0
|
Provenance
The following attestation bundles were made for dirigex_sdk-0.1.0-py3-none-any.whl:
Publisher:
sdk-publish-py.yml on DirigexAI/Dirigex
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dirigex_sdk-0.1.0-py3-none-any.whl -
Subject digest:
c31d596d041b014f9d59fbc5e0300ae942e041098c56687611c67f29d632e0f6 - Sigstore transparency entry: 2025699011
- Sigstore integration time:
-
Permalink:
DirigexAI/Dirigex@0b1fac6f2002ab574cd32f79e4e14628d3a3df4a -
Branch / Tag:
refs/heads/codex/python-sdk-publish-fix - Owner: https://github.com/DirigexAI
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
sdk-publish-py.yml@0b1fac6f2002ab574cd32f79e4e14628d3a3df4a -
Trigger Event:
workflow_dispatch
-
Statement type: