asertu Optimizer Python SDK
SDK oficial de Python para asertu Optimizer, el producto de observabilidad, coste y optimizacion del uso de IA de la plataforma general asertu.
Version actual estable: 1.0.2
Este repositorio contiene exclusivamente el SDK Python oficial del producto asertu Optimizer. La API del SDK esta pensada para integrarse de forma natural en aplicaciones que ya usan LLMs y necesitan registrar eventos, consultar analitica e incorporar historial e insights sin tratar asertu como un cliente REST generico.
Estado actual
La base del SDK ya incluye:
- cliente oficial
AsertuOptimizerClient - auth por
tenant_api_key,bearer_tokenytenant_id - eventos de observabilidad LLM
- tenants
- paginacion de tenants con
limit,cursore iteracion completa - analytics
- history
- billing
- settings
- paginacion adicional en
settings.members,settings.access_requestsysettings.invitations - insights y recommendations
- helpers para OpenAI, Anthropic y Bedrock
- constructor
AsertuOptimizerClient.from_env() - cliente async
AsyncAsertuOptimizerClient - telemetria opcional del SDK
- tests, ejemplo ejecutable y documentacion del repo
Documentacion
La documentacion funcional y de producto se referencia desde optimizer.asertu.ai.
Tambien puedes navegar el material tecnico directamente en el repositorio oficial:
En esta release publica inicial, el SDK se centra en:
- ingesta de eventos de observabilidad de IA
- discovery de tenants para usuarios autenticados
- analytics, insights, recommendations e history tenant-scoped
- billing y settings de workspace
- helpers para OpenAI, Anthropic y Bedrock
- soporte sync y async
Instalacion
pip install asertu-optimizer
Para desarrollo local:
python3 -m pip install -e ".[dev]"
Uso rapido
from asertu_optimizer import AsertuOptimizerClient
client = AsertuOptimizerClient.from_env()
client.events.track_openai_call(
model="gpt-4.1-mini",
feature="support_chat",
input_tokens=1200,
output_tokens=800,
status="success",
)
Para consultas tenant-scoped:
client = AsertuOptimizerClient(
base_url="https://api.optimizer.asertu.ai",
bearer_token="jwt-token",
tenant_id="tenant-123",
)
summary = client.analytics.dashboard_summary(preset="today")
Uso async:
from asertu_optimizer import AsyncAsertuOptimizerClient
async_client = AsyncAsertuOptimizerClient.from_env()
summary = await async_client.analytics.dashboard_summary(preset="today")
await async_client.aclose()
Contrato actual
El SDK toma como fuente de verdad el Swagger publicado del producto en optimizer.asertu.ai. Revalidado hoy, 7 de abril de 2026, el contrato publicado sube a version: 1.24.11 y cubre events, tenants, analytics, insights, recommendations, history, billing y settings.
Para eventos de ingesta, el contrato publico actual documenta ai.request.completed como valor por defecto recomendado para event_type, y el SDK queda alineado con ese comportamiento.
Los endpoints paginables publicados hoy son:
GET /v1/tenantsGET /v1/settings/membersGET /v1/settings/access-requestsGET /v1/settings/invitations
El SDK cubre esos flujos con limit, cursor e iteradores completos iter_all_*() tanto en sync como en async. En settings.invitations tambien expone resolve_invitation(token=...) para el flujo publico por token.
El SDK expone unicamente metodos respaldados por el Swagger/OpenAPI publicado. No incluye administracion global de plataforma ni placeholders para endpoints fuera del contrato.
Compatibilidad de proveedores
La compatibilidad documental de los helpers de instrumentacion esta verificada a fecha 2026-03-27 y se apoya en la documentacion oficial de cada proveedor.
En este momento:
- OpenAI: compatible con respuestas tipo
Responses APIy modelos comogpt-4.1-mini - Anthropic: compatible con
Messages APIy modelos documentados comoclaude-sonnet-4-20250514 - Bedrock: compatible con respuestas tipo
Conversey modelos comoanthropic.claude-sonnet-4-20250514-v1:0
Metadata
Release files for asertu-optimizer 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| asertu_optimizer-1.0.2.tar.gz | 34.1 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| asertu_optimizer-1.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 68.7 kB
Release files / asertu_optimizer-1.0.2.tar.gz
| Download URL | asertu_optimizer-1.0.2.tar.gz |
|---|---|
| Size | 34.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f0501211e87007953a04b3782a32587e1973dd37f2516095aea20b14914cf58f
|
|
BLAKE2b-256 checksum How to use checksums |
c277974514afdc1675a6d30b2528b8e589ae586e42203b3d82a5a34ddd328c8d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Apr 7, 2026.
Transparency logRelease files / asertu_optimizer-1.0.2-py3-none-any.whl
| Download URL | asertu_optimizer-1.0.2-py3-none-any.whl |
|---|---|
| Size | 34.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ef07f649ed3c07d13aa1ece2f672c6fb4b70131ba05d3b5f442ce837c73d1048
|
|
BLAKE2b-256 checksum How to use checksums |
e23a40cfd9e3b1aff794aa1878148773af644b321e94995e51a93bf3ec10337c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Apr 7, 2026.
Transparency logSecurity for asertu-optimizer 1.0.2
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for asertu_optimizer-1.0.2.tar.gz
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 Apr 7, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.