Yet Another LLM Client
Project description
Yet Another LLM Client
An opinionated python wrapper for LLM calls. Supports multiple LLM providers:
- OpenAI
- Anthropic
- more to come...
Uses pydantic models to serialize LLM responses. Every response has to be serialized into a pydantic model.
Full async support.
Checking models
To verify which models in LLMModel are reachable with your current API keys:
cp .env.example .env # fill in your API keys
uv run python scripts/check_models.py
Each model is called concurrently and results print as they complete.
Usage
Every call to the LLM returns some metadata. Metadata contains token usage, costs, model used and context messages. YALC supports 2 modes of operations for handling metadata.
Metadata return mode
Metadata is returned directly alongside the response as a tuple.
client = create_client(LLMModel.gpt_4o_mini)
result, metadata = await client.structured_response(
JudgmentResult, messages
)
Advantages:
- Simple, no setup required
- Direct access to metadata at the call site
Disadvantages:
- Must handle metadata manually on every call
- Easy to forget or handle inconsistently across call sites
Strategy metadata mode
A metadata handler strategy is provided during client creation. The strategy is automatically invoked on every call when a context is passed. The provided context is used for any additional data that needs to be used when handling LLM call metadata.
# 1. Define your strategy
class LogStrategy(ClientMetadataStrategy[LLMLogContext]):
def handle(self, call: ClientCall, context: LLMLogContext):
print(f"Tokens: {call.input_tokens + call.output_tokens}")
print(f"Cost: {call.input_tokens_cost + call.output_tokens_cost}")
db.save(call.model_dump(), context.request_id)
# 2. Create client with the strategy
client = create_client(LLMModel.gpt_4o_mini, metadata_strategies=[LogStrategy()])
# 3. Pass context to trigger the strategy
result = await client.structured_response(
JudgmentResult, messages, context=llm_log_context
)
Advantages:
- Metadata handling is set up once and applied consistently
- Call sites stay clean — no need to unpack or handle metadata each time
Disadvantages:
- More initial setup
- Metadata handling is implicit, which can be harder to trace
Project details
Release history Release notifications | RSS feed
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 yalc-0.3.1.tar.gz.
File metadata
- Download URL: yalc-0.3.1.tar.gz
- Upload date:
- Size: 110.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c3063ff27db53be20918cdb9ebc908a5d9aed20ddcae65e6697975d24ed39f0
|
|
| MD5 |
5820ccccc7c4bdc6deedb43c8dc16a45
|
|
| BLAKE2b-256 |
2222fc6ed031f1ae8a73525c0ee2f95558699f134d4382d039cb98305a99e895
|
Provenance
The following attestation bundles were made for yalc-0.3.1.tar.gz:
Publisher:
publish.yml on cognitai-labs-dev/yalc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
yalc-0.3.1.tar.gz -
Subject digest:
6c3063ff27db53be20918cdb9ebc908a5d9aed20ddcae65e6697975d24ed39f0 - Sigstore transparency entry: 1243018927
- Sigstore integration time:
-
Permalink:
cognitai-labs-dev/yalc@c7b1666a8bab0c3f5fd42e62afc490e643f5ec06 -
Branch / Tag:
refs/tags/v0.3.1 - Owner: https://github.com/cognitai-labs-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c7b1666a8bab0c3f5fd42e62afc490e643f5ec06 -
Trigger Event:
push
-
Statement type:
File details
Details for the file yalc-0.3.1-py3-none-any.whl.
File metadata
- Download URL: yalc-0.3.1-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3c22a67132cd70ff699f70565e4f63033b0eadff4e6d0019de6484d0039f64a2
|
|
| MD5 |
f0e68fc05336000e89570719a2a42468
|
|
| BLAKE2b-256 |
4ef325a8b085e56a1742ea3a259686909d198496b3e938292d41e443ed55f038
|
Provenance
The following attestation bundles were made for yalc-0.3.1-py3-none-any.whl:
Publisher:
publish.yml on cognitai-labs-dev/yalc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
yalc-0.3.1-py3-none-any.whl -
Subject digest:
3c22a67132cd70ff699f70565e4f63033b0eadff4e6d0019de6484d0039f64a2 - Sigstore transparency entry: 1243018932
- Sigstore integration time:
-
Permalink:
cognitai-labs-dev/yalc@c7b1666a8bab0c3f5fd42e62afc490e643f5ec06 -
Branch / Tag:
refs/tags/v0.3.1 - Owner: https://github.com/cognitai-labs-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c7b1666a8bab0c3f5fd42e62afc490e643f5ec06 -
Trigger Event:
push
-
Statement type: