anvaya-sdk — Python SDK
Standard library only. No requests, no pydantic, no transitive anything.
pip install anvaya-sdk
⚠️ Install anvaya-sdk, import anvaya. The bare name anvaya on PyPI
belongs to an unrelated mathematics library by another author — pip install anvaya fetches that, not this. The import name is unchanged.
import anvaya
anvaya.init(api_key="anv_prod_...", endpoint="https://api.anvaya.dev")
with anvaya.span("llm.answer", kind="llm", provider="anthropic") as s:
response = model.complete(prompt)
s["outputTokens"] = response.usage.output_tokens
The handle yielded by span() is a plain dict; assigning to it before the
block exits adds fields to the span. The block is timed automatically, and an
exception raised inside it is recorded as status="error" with the exception's
type name — and then re-raised. The SDK never swallows your exception.
Configuration
| Argument | Environment | Default |
|---|---|---|
api_key |
ANVAYA_API_KEY |
"" |
endpoint |
ANVAYA_ENDPOINT |
http://localhost:4318 |
environment |
— | production |
batch_size |
— | 256 |
flush_interval |
— | 5.0 s |
queue_limit |
— | 10 000 spans |
With no API key the client is inert: no thread, no timer, no network, no exception. A developer running your test suite without credentials gets silence rather than a stack trace or a hang.
What it will not do
Each of these has a test in tests/, and a matching test in the Node SDK.
- Raise into your request path. The only exception this package raises is
SpanError, and only for genuinely malformed instrumentation — at the line that wrote it, not from a background thread pointing somewhere else. Transport failures, 5xx responses, a dead endpoint and a full queue are all counters, readable viaclient.stats(). - Send your prompts.
content=is hashed to asha256:reference. The payload goes only where you configure it to. - Hold your process open. The flush thread is a daemon and
close()is registered withatexit. - Retry a 402, 401 or 403. A quota rejection means the fix is commercial; a bad credential does not fix itself. The client disables itself and says so once.
- Requeue a failed batch. A queue that refills faster than it drains during an outage is how an SDK causes the memory exhaustion it was meant to observe.
- Drop the newest span under pressure. It drops the oldest. During an incident the newest spans are the ones describing it.
- Guess a timestamp. An unparseable
startedAtraises rather than defaulting tonow()— a span stamped with its arrival time looks correct and poisons every latency number derived from it.
Tests
No test dependencies either:
py -m unittest discover -s tests # Windows
python3 -m unittest discover -s tests # everywhere else
tests/test_conformance.py reads ../conformance/corpus.json, the same file
the Node SDK and the control plane are tested against. See
../README.md for why that file exists.
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 anvaya_sdk-0.1.0.tar.gz.
File metadata
- Download URL: anvaya_sdk-0.1.0.tar.gz
- Upload date:
- Size: 24.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
edcee721499ca10eb14113adab80e1f97bfd2f89ea2e8a3389651be7112acad9
|
|
| MD5 |
9a33757d7d59cfd2f0e0b57d7714d629
|
|
| BLAKE2b-256 |
17547ea0106272d05aa63a5c1a920cdfe85a4a4a46660cf281597d613f6f8b76
|
Provenance
The following attestation bundles were made for anvaya_sdk-0.1.0.tar.gz:
Publisher:
publish-python-sdk.yml on siddhashutosh/anvaya-platform
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
anvaya_sdk-0.1.0.tar.gz -
Subject digest:
edcee721499ca10eb14113adab80e1f97bfd2f89ea2e8a3389651be7112acad9 - Sigstore transparency entry: 2373181132
- Sigstore integration time:
-
Permalink:
siddhashutosh/anvaya-platform@d917e589d61678237e209b8603befac4ddc8d77d -
Branch / Tag:
refs/heads/main - Owner: https://github.com/siddhashutosh
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python-sdk.yml@d917e589d61678237e209b8603befac4ddc8d77d -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file anvaya_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: anvaya_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 19.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ed5c487a22a8dd6fa9f1ba619b4ae354ed83df6374118a8ebdc714978ddbccd
|
|
| MD5 |
ae6f5ea8673f63578ad30ce51bacb799
|
|
| BLAKE2b-256 |
a4e20cc4047b63b09ed5a841fa3092154db7e83d359a7e266a4b8d657f705bbe
|
Provenance
The following attestation bundles were made for anvaya_sdk-0.1.0-py3-none-any.whl:
Publisher:
publish-python-sdk.yml on siddhashutosh/anvaya-platform
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
anvaya_sdk-0.1.0-py3-none-any.whl -
Subject digest:
8ed5c487a22a8dd6fa9f1ba619b4ae354ed83df6374118a8ebdc714978ddbccd - Sigstore transparency entry: 2373181166
- Sigstore integration time:
-
Permalink:
siddhashutosh/anvaya-platform@d917e589d61678237e209b8603befac4ddc8d77d -
Branch / Tag:
refs/heads/main - Owner: https://github.com/siddhashutosh
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python-sdk.yml@d917e589d61678237e209b8603befac4ddc8d77d -
Trigger Event:
workflow_dispatch
-
Statement type: