adlib-client
A Python wrapper for monetizing LLM output with AdLib.
Install
Install from PyPI:
pip install adlib-client
Required API keys
AdLib requires two keys:
ADLIB_API_KEY=your_adlib_api_key_here
ADLIB_CHATBOT_PUBLIC_KEY=your_chatbot_public_key_here
You can provide them using environment variables (in a .env file) or directly when creating AdLib():
from adlib_client import AdLib
adlib = AdLib(
adlib_api_key="your_adlib_api_key_here",
adlib_chatbot_api_key="your_chatbot_public_key_here",
)
Authorization on Initialization
When you create an instance of AdLib(), it automatically attempts to validate your credentials against the AdLib service.
- Success: The object is initialized and ready for use.
- Missing Keys: If either key is missing (and not found in environment variables), an
Exceptionis raised immediately. - Invalid Keys: If the keys are provided but rejected by the server, a
ValueErroris raised with the specific error message from the service.
Basic usage
from adlib_client import AdLib
# Automatically loads keys from environment or .env
adlib = AdLib()
llm_output = "Here is the answer from your model."
adified_output = adlib.adify(llm_output)
print(adified_output)
adlib.adify() sends text to AdLib and returns the final transformed output string. If an ad is inserted, it's included in the string; otherwise, the original text is returned.
Use AdLib as a decorator
You can wrap your generation functions directly:
from adlib_client import AdLib
adlib = AdLib()
@adlib.adify
def generate_answer(prompt: str) -> str:
# Your LLM logic here
answer = ...
return answer
# The returned value is now automatically adified
print(generate_answer("What is the weather?"))
Error Handling
- Initialization:
Exceptionfor missing keys,ValueErrorfor invalid keys. - Network Errors: Failed HTTP requests raise standard
requestsexceptions (e.g., connection issues). - Service Errors: If the adify service fails during a call,
adify()safely returns the original LLM output.
Notes
adlib.adify()returns the transformed text string directly.- Use
adifywhen you want to wrap LLM outputs or decorate generation functions.
Metadata
Release files for adlib-client 0.1.9
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 |
|---|---|---|---|---|
| adlib_client-0.1.9.tar.gz | 3.2 kB | Without provenance | Details for adlib_client-0.1.9.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| adlib_client-0.1.9-py3-none-any.whl | Python 3 | none | any | Details for adlib_client-0.1.9-py3-none-any.whl |
Total release size: 6.8 kB
Release files / adlib_client-0.1.9.tar.gz
| Download URL | adlib_client-0.1.9.tar.gz |
|---|---|
| Size | 3.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
10be0a44bb1f5619eec0183d366b008283522f110544ba668524266fde59ecbc
|
|
BLAKE2b-256 checksum How to use checksums |
8e9959f81650060aa4d097718e30a59c953f00954f1b2dd59bb0e664b9600cfc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / adlib_client-0.1.9-py3-none-any.whl
| Download URL | adlib_client-0.1.9-py3-none-any.whl |
|---|---|
| Size | 3.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
94e6128543727416a1be27e59ce29aa829cc4c45553770d86adc8f3e59263a18
|
|
BLAKE2b-256 checksum How to use checksums |
7911fc48cb5c41c31e2414292851b838112be9e55394a4f6195e6b9cd1d596b4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Security for adlib-client 0.1.9
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.