Cliente Python para validar y consumir cuota del Robin Quota Service
Project description
robin-quota-client
Cliente Python mínimo para integrar cualquier proyecto con el Robin Quota Service: validar disponibilidad y consumir cuota.
El modelBotId no es necesario — el servicio lo resuelve desde la X-Docker-Api-Key (apiServices.modelBotId). Solo pásalo si usas una key legacy sin bot asociado en BD.
Instalación
pip install -e .
# o con tests
pip install -e ".[dev]"
Uso
from robin_quota import QuotaClient, QuotaExceededError
client = QuotaClient(
api_key="robin_docker_...",
host="http://localhost:3201", # test local (npm run dev)
source="ai-gen-message",
)
# 1. Validar antes de generar mensaje IA
client.ensure_can_send()
# 2. Generar respuesta IA...
# ai_reply = llm.generate(...)
# 3. Consumir cuota (+1)
client.consume(
idempotency_key="msg-123",
workflow_room_id="f7027893-08c9-4216-96b2-8998a5b967f6",
workflow_id="uuid-del-workflow",
metadata={"origin": "app.ruvic.ai"},
)
Parámetros
Inicialización (QuotaClient)
| Parámetro | Requerido | Descripción |
|---|---|---|
api_key |
sí | Docker API key del despliegue |
host |
no | URL base (default http://localhost:3201) |
source |
no | Origen para consume() (default python-agent) |
model_bot_id |
no | Solo keys legacy sin bot en apiServices |
consume()
| Parámetro | Requerido | Descripción |
|---|---|---|
quantity |
no | Default 1 |
idempotency_key |
recomendado | Evita doble conteo en reintentos |
workflow_room_id |
no | Contexto/auditoría (workFlowRoomId) |
workflow_id |
no | Contexto/auditoría (workFlowId) |
metadata |
no | JSON libre adicional |
Variables de entorno (opcional)
export ROBIN_QUOTA_API_KEY=robin_docker_...
export ROBIN_QUOTA_BASE_URL=http://localhost:3201
export ROBIN_QUOTA_SOURCE=ai-gen-message
# ROBIN_QUOTA_MODEL_BOT_ID solo para keys legacy
Tests
pytest # unit tests (mocks)
pytest tests/test_integration.py # contra localhost:3201 si está corriendo
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 robin_quota_client-0.1.0.tar.gz.
File metadata
- Download URL: robin_quota_client-0.1.0.tar.gz
- Upload date:
- Size: 10.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
985d838c2459ef09e76af1a6ab237378348b968c00bcabefc2d4460d3dcbd5d2
|
|
| MD5 |
d08894895b750ef9c89d80171bc6b592
|
|
| BLAKE2b-256 |
724f7f4faf39bff9e259053d753beac7353451ccc02e0ab46d3cd5bb739a67bc
|
File details
Details for the file robin_quota_client-0.1.0-py3-none-any.whl.
File metadata
- Download URL: robin_quota_client-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7bd774f8f92754e7489bd1fd29ff89d3f488aae750d279616411d1c984c7fe5
|
|
| MD5 |
08761a91177267c28a282f509f61c913
|
|
| BLAKE2b-256 |
8313919f61ec42e1e801a00c98032370bc05d84169f7b5cdafb01f58b884ea17
|