AI gateway SDK — cost control, session tracing, and security for LLM agents
Project description
nolma
AI gateway SDK — cost control, session tracing, and security for LLM agents.
One URL change. See every dollar your AI agents spend.
Installation
pip install nolma
Quick start
from nolma import Nolma
nolma = Nolma(api_key="nm_live_abc123")
@nolma.session(name="support-bot", user_id="user_42")
async def my_agent(query: str):
# Your LLM calls go here — Nolma tracks everything
...
Session decorator
Wraps your agent function with automatic session tracking via contextvars:
@nolma.session(name="research-agent", user_id="user_123")
async def research(topic: str):
result = await llm_call(topic)
return result
Context manager
async with nolma.start_session(name="email-drafter") as ctx:
print(ctx.session_id) # sess_abc123...
result = await draft_email(input)
Header injection
Pass Nolma headers to any LLM SDK:
import anthropic
client = anthropic.Anthropic(
base_url=nolma.gateway_url + "/anthropic",
default_headers=nolma.get_headers(),
)
Signals (Nolma Lens)
Track what users do with LLM outputs:
nolma.signal(session_id, action="accepted")
nolma.signal(session_id, action="edited", edit_distance=42)
nolma.signal(session_id, action="regenerated")
Context scanning (Nolma Shield)
Detect injection attacks in RAG content:
result = await nolma.scan_context(
content=retrieved_doc,
source="rag",
agent="support-bot",
)
if result["decision"] == "BLOCK":
raise SecurityError("Injection detected")
Documentation
Full docs at docs.nolma.ai
License
MIT
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 nolma-0.1.0.tar.gz.
File metadata
- Download URL: nolma-0.1.0.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a8af2cdeb25127c38152520242646325ce958862fb59b28efa451f0066859b90
|
|
| MD5 |
be28a248b444506f283ef3b4df64cce6
|
|
| BLAKE2b-256 |
8d905ceb5cc8bf8ee45bd108515d40a084e50fd238e2e410dec5039cd4bf7ea3
|
File details
Details for the file nolma-0.1.0-py3-none-any.whl.
File metadata
- Download URL: nolma-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
29a51c4c01377ea80212f76173c7ddd19792cd48fd9ad6e70f81f76d3581785f
|
|
| MD5 |
4ec51c38a5d34c699c63d25e774222b9
|
|
| BLAKE2b-256 |
db52c7b43ab9ff56597160d5f160b6b9ed2028d61e34eed4213e2965476dca8c
|