medullabs
Official Python client for the MedullaAI API.
- Upload an image once, then run any analysis against it.
- Timeouts, retries and idempotency keys are handled for you, so a retry never charges twice.
- Sync and async clients, fully typed.
- Python 3.9 or newer. One dependency:
httpx.
Server-side only. Your API key is a secret. Call the API from your backend, never from code that runs on your users' devices.
Full documentation: https://platform.medullabs.com/docs/sdks/python
Install
pip install medullabs
Quickstart
from medullabs import Medullabs
client = Medullabs() # reads the MEDULLABS_API_KEY environment variable
# 1. Upload once. Free.
media = client.media.upload("creative.png")
# 2. Run analyses against the uid.
attention = client.attention(uid=media.uid)
load = client.cognitive_load(uid=media.uid, industry="FMCG")
print(load.charged_credits, load.result)
Async
import asyncio
from medullabs import AsyncMedullabs
async def main() -> None:
async with AsyncMedullabs() as client:
media = await client.media.upload("creative.png")
r = await client.attention(uid=media.uid)
print(r.charged_credits)
asyncio.run(main())
Methods
| Method | API | Credits |
|---|---|---|
media.upload(file) |
POST /v1/media |
free |
media.get(uid) / media.delete(uid) |
GET / DELETE /v1/media/{uid} |
free |
industries() |
GET /v1/industries |
free |
attention(uid=) |
POST /v1/attention |
2 |
cognitive_load(uid=, industry=) |
POST /v1/cognitive-load |
1 |
focus_score(uid=, industry=) |
POST /v1/focus-score |
1 |
emotion(uid=, industry=, human_present=) |
POST /v1/emotion |
1 |
aoi(uid=, final_dict=, industry=None) |
POST /v1/aoi |
3 |
analyze(uid=, industry=, human_present=, final_dict=) |
POST /v1/analyze |
5 |
validate(uid=, campaign_objective=, industry=, ...) |
POST /v1/validate |
3 |
media.upload accepts a file path, bytes, or a file opened in binary mode (open(path, "rb")).
Every analysis returns a FeatureResult with request_id, uid, status, feature,
charged_credits (an int), result (a dict, overlays inline as base64), created_at,
finished_at, replayed (True for a free replay) and rate_limit.
Errors
Every error is a MedullabsError with code, status, message, details, request_id
(quote it to support) and idempotency_key.
from medullabs import InsufficientCreditsError, RateLimitError, ValidationError
try:
client.emotion(uid=uid, industry="FMCG", human_present=True)
except InsufficientCreditsError:
... # top up
except RateLimitError as e:
... # wait e.retry_after seconds
except ValidationError as e:
print(e.message) # e.g. "industry: Invalid enum value"
Classes: ValidationError (400/422), AuthenticationError (401), InsufficientCreditsError
(402), PermissionDeniedError (403), NotFoundError (404), ConflictError (409),
RateLimitError (429), ServerError (5xx), APIConnectionError and APITimeoutError (no
response). You are never charged for a failed call.
Retries and timeouts
The client retries server errors, dropped connections and short rate-limit waits, up to
max_retries (default 2), reusing the same Idempotency-Key so a retry never charges twice.
The default timeout is 400 seconds, enough for the slowest analysis.
client = Medullabs(
api_key="sk_live_...", # or MEDULLABS_API_KEY
timeout=400.0, # seconds per attempt
max_retries=2,
max_retry_wait=60.0, # longest Retry-After to wait out automatically
)
License
MIT
Metadata
Release files for medullabs 0.1.0
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 | Actions |
|---|---|---|---|---|
| medullabs-0.1.0.tar.gz | 17.9 kB | With provenance | Details for medullabs-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| medullabs-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for medullabs-0.1.0-py3-none-any.whl |
Total release size: 33.4 kB
Release files / medullabs-0.1.0.tar.gz
| Download URL | medullabs-0.1.0.tar.gz |
|---|---|
| Size | 17.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dd0bb23ee342732fd9f7aff33ec8669142fb8bfbbd69158c98232ddb27ff3881
|
|
BLAKE2b-256 checksum How to use checksums |
bf02c1dc4cf8ec34ece23ebfa711f1e0d8368c698a14d050ef7b35036f404dae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 12, 2026.
Transparency logRelease files / medullabs-0.1.0-py3-none-any.whl
| Download URL | medullabs-0.1.0-py3-none-any.whl |
|---|---|
| Size | 15.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e94bdde3203e3bc257e2140ad8d654d05ee85b99da12845c6736be12a0187a69
|
|
BLAKE2b-256 checksum How to use checksums |
9c4919c22b01276ded1fb9cc4d325b290cf32410d91ffcc07ecb11546d912dca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 12, 2026.
Transparency logSecurity for medullabs 0.1.0
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
Both files in this release have been uploaded with provenance metadata.
Attestation for medullabs-0.1.0.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 Nov 12, 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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.