Repository navigation
This is the current stable release of the Adstract AI Python SDK.
The SDK API is stable and production-ready. Version 1.0.1 includes the
stable 1.0.0 surface together with the latest acknowledgment response model
and backend-aligned exception handling.
What's new in v1.0.1
Structured acknowledgment responses
Successful acknowledge and acknowledge_async calls now return an
AdAckResponse object with:
ad_ack_idstatussuccess
Acknowledgment status now reflects the finalized backend contract:
ok→ acknowledgment completed successfullyno_ad_used→ acknowledgment completed successfully, but the final LLM response did not use the adrecoverable_error→ acknowledgment was accepted, but Adstract encountered a recoverable backend-side issue during follow-up processing
Acknowledgment-specific exception types
Known acknowledgment failures now map to dedicated SDK exceptions:
AdResponseNotFoundErrorUnsuccessfulAdResponseErrorDuplicateAcknowledgmentError
This makes acknowledgment error handling explicit instead of treating these
cases as generic unexpected responses.
Backend-aligned HTTP error mapping
Enhancement and acknowledgment methods now match the current backend behavior
for:
- bad API key format
- missing or invalid API key
- revoked API key
- inactive platform or publisher state
- duplicate ad requests
- duplicate acknowledgments
- unsuccessful acknowledgment targets
Included from v1.0.0
Optional targeting context
Pass an OptionalContext to request_ad / request_ad_async to provide
additional signals for ad targeting: country, region, city, ASN, age, and
gender. All fields are optional and validated.
Status-based enhancement error types
The enhancement response status field maps to specific error classes:
PromptRejectedError— prompt was not suitable for ad injectionNoFillError— prompt was suitable but no ad inventory was available
Both are subclasses of AdEnhancementError.
Cleaner API naming
AdRequestContext.x_forwarded_for→user_ipAdResponse.prompt→enhanced_promptanalyse_and_report/analyse_and_report_async→acknowledge/acknowledge_async
Breaking changes carried into the stable API
From v0.4.0
AdRequestContext.x_forwarded_forrenamed touser_ipAdResponse.promptrenamed toenhanced_promptanalyse_and_reportrenamed toacknowledgeanalyse_and_report_asyncrenamed toacknowledge_async
From v0.3.x
AdRequestConfigurationrenamed toAdRequestContextrequest_ad_or_defaultrenamed torequest_adrequest_ad_or_default_asyncrenamed torequest_ad_asyncrequest_ad,request_ad_async,acknowledge, andacknowledge_async
now raise exceptions by default — setraise_exception=Falsefor
graceful fallback behavior- Analytics, compliance, and metadata processing moved to the backend, and
the related SDK-side model classes were removed
Install
pip install adstractai==1.0.1