Uprelic Python SDK
pip install uprelic
Set UPRELIC_API_KEY (create a key at https://platform.uprelic.com), or pass api_key= to the client.
from uprelic import Uprelic, Noul, Choice, Score
client = Uprelic()
response = client.system_one(
model="strom-1.0.7",
state="I was charged twice for my subscription. Please fix this today.",
questions={
"billing": Noul("Is this message about billing?"),
"tone": Choice("What is the tone?", criteria={"angry": "Upset or hostile", "calm": "Neutral or polite"}),
"urgency": Score("How urgent is this?", criteria=["Can wait", "This week", "Today"]),
},
)
response.nouls["billing"].noul # 0.98
response.choices["tone"].choice # "angry"
response.scores["urgency"].score # 1.8
response.usage.input_tokens
response.usage.cost # in response.usage.currency
response.metadata.server_processing_time_ms
Images go in images= as http(s) or data:image/... URLs. client.models() lists the available models.
Document extraction
client.extract() takes one PDF (at most 8 pages) or image and a JSON Schema whose properties are the fields to
extract: strings (format: date), numbers (format: amount or percent), booleans or string enums.
from pathlib import Path
response = client.extract(
model="strom-1.0.7",
document=Path("invoice.pdf"), # or bytes, or an http(s) or data: URL
schema={"properties": {
"invoice_date": {"type": "string", "format": "date"},
"total": {"type": "number", "format": "amount", "description": "The total including tax"},
}},
)
response.fields["total"].value # 1234.5
response.fields["total"].text # "Total EUR 1.234,50", the line it came from
response.fields["total"].confidence # 0.94
response.fields["total"].page, response.fields["total"].box
A field the document doesn't give is None. When the line holds more than one value of the field's type, value is
the whole line.
Async
from uprelic import AsyncUprelic
async with AsyncUprelic() as client:
response = await client.system_one(model="strom-1.0.7", state="...", questions={...})
Errors and retries
Failed requests raise uprelic.APIError subclasses: AuthenticationError (401), InsufficientBalanceError (402),
InvalidRequestError (400, 413, 422), RateLimitError (429) and ServerError (5xx). Each has status_code and detail.
Rate limits (429), 502/503/504 responses and connection failures are retried twice with backoff. Change this with
Uprelic(max_retries=...).
API reference: https://api.uprelic.com/v1/docs
Metadata
Release files for uprelic 0.3.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 |
|---|---|---|---|---|
| uprelic-0.3.0.tar.gz | 6.2 kB | Without provenance | Details for uprelic-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| uprelic-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for uprelic-0.3.0-py3-none-any.whl |
Total release size: 12.2 kB
Release files / uprelic-0.3.0.tar.gz
| Download URL | uprelic-0.3.0.tar.gz |
|---|---|
| Size | 6.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3f748451b44b3e5d61f44b0bf7aff8c1eb6b33a5a534a60c90b1ef4deda9db41
|
|
BLAKE2b-256 checksum How to use checksums |
4510392d0a90b42b287003894330241ffe801829e9401c6975648cc53e146349
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / uprelic-0.3.0-py3-none-any.whl
| Download URL | uprelic-0.3.0-py3-none-any.whl |
|---|---|
| Size | 6.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d4fc899f47aeacc912a993e033b27bc740e9963ea73a3f290cde306666cca339
|
|
BLAKE2b-256 checksum How to use checksums |
3f24f0b23f599fe458e801945913668ca55ac1692790020b6b68d43a84fa944b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Security for uprelic 0.3.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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.