Use it with any LLM model and custom agents (not limited to OpenAI).
To get started, get a project ID by registering here.
🛠️ Installation
pip install lunary
🤖 Anthropic Integration
from anthropic import Anthropic
import lunary
client = Anthropic()
lunary.monitor(client)
parsed = client.messages.parse(
model="claude-sonnet-4-5-20250929",
max_tokens=256,
messages=[{"role": "user", "content": "Return JSON with an answer field for 2 + 2."}],
output_format=dict,
)
with client.messages.stream(
model="claude-sonnet-4-5-20250929",
max_tokens=256,
messages=[{"role": "user", "content": "Stream one sentence about Lunary."}],
) as stream:
for event in stream:
pass
Diagnosing event delivery errors
Keep LUNARY_VERBOSE unset or false in production and capture ERROR logs from lunary.consumer. Each failed send produces one line explaining what happened and whether the SDK will retry. It includes the exception type, HTTP status when available, and the number of events in the batch.
Error sending events. Invalid API key. Batch will not be retried. error_type=HTTPError http_status=401 batch_size=3.
Error sending events. The endpoint rate-limited the request. Batch will not be retried. error_type=HTTPError http_status=429 batch_size=3.
Error sending events. The ingestion service or gateway is unavailable. Batch will not be retried. error_type=HTTPError http_status=503 batch_size=3.
Error sending events. The endpoint did not respond in time. Batch will not be retried. error_type=ReadTimeout http_status=n/a batch_size=3.
| Diagnostic | First checks |
|---|---|
| HTTP 401 / 403 | Project API key and access configuration. |
| HTTP 402 | Project ID format or account billing/access status; the ingestion API also uses this status for a malformed project ID. |
| HTTP 400 / 422 | Event format and SDK version. |
| HTTP 404 | Configured API endpoint or proxy routing. |
| HTTP 413 | Event payload size and proxy request limits. |
| HTTP 429 | Rate limits at the service or gateway. |
| HTTP 5xx | Ingestion service or gateway failure; correlate timestamps with service logs. |
ConnectionError |
DNS, connectivity, firewall, proxy, or remote connection failure. |
SSLError / ProxyError |
Certificate trust or proxy configuration and availability. |
Timeout / ConnectTimeout / ReadTimeout |
Connection or response delay; these do not identify which side caused it. |
| Other exception types | SDK/runtime or serialization failure; provide the type and SDK version when reporting it. |
For recognized API key, project and billing failures, the SDK uses the API's fixed explanation. For other responses it describes the HTTP status or exception type. Normal logs omit arbitrary server text, request URLs, credentials, event payloads and tracebacks. Verbose mode retains full tracebacks and can log event contents. Share the timestamp, SDK version and diagnostic line with support.
The consumer removes a batch from its in-memory queue before sending and does not automatically retry a failed send. An error therefore does not mean the batch will eventually be delivered; after a connection failure, server acceptance may also be uncertain. This diagnostic change does not add retries, a timeout, persistence, or recovery of missing traces.
📖 Documentation
Full docs are available here.
Metadata
Release files for lunary 1.4.42
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 |
|---|---|---|---|---|
| lunary-1.4.42.tar.gz | 41.1 kB | Without provenance | Details for lunary-1.4.42.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lunary-1.4.42-py3-none-any.whl | Python 3 | none | any | Details for lunary-1.4.42-py3-none-any.whl |
Total release size: 86.7 kB
Release files / lunary-1.4.42.tar.gz
| Download URL | lunary-1.4.42.tar.gz |
|---|---|
| Size | 41.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b87cf606473f0745a379893a6953c00a60af10cbdc22c841ea8405f3a760ba2a
|
|
BLAKE2b-256 checksum How to use checksums |
a27d544496d92d768352458c05df4995946aaa2a9667216111a31b0523ac31ef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.3.3 CPython/3.12.14 Darwin/27.2.0
|
Release files / lunary-1.4.42-py3-none-any.whl
| Download URL | lunary-1.4.42-py3-none-any.whl |
|---|---|
| Size | 45.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
190dc2d048a4b7b63277790e4cde13007dffaf9aebcb60a2b34fb5a70cc1c67e
|
|
BLAKE2b-256 checksum How to use checksums |
e705efe1b2d6a51a692e8bc58e5b865fde0b8cbfb230d52b446cb29b7fe25422
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.3.3 CPython/3.12.14 Darwin/27.2.0
|
Security for lunary 1.4.42
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.