Agent economics SDK — track ROI, KPIs, and cost for AI agents in 2 lines of code
Project description
VelenAI SDK
Agent economics in 2 lines of code. Track ROI, KPIs, and cost for your AI agents.
Langfuse is the debugger. VelenAI is the CFO.
Install
pip install velenai
With provider wrappers and framework adapters:
pip install velenai[anthropic] # Anthropic auto-capture
pip install velenai[openai] # OpenAI auto-capture
pip install velenai[crewai] # CrewAI adapter
pip install velenai[langgraph] # LangGraph adapter
pip install velenai[autogen] # AutoGen adapter
Quick Start
from velenai import VelenAI # or: from velenai_sdk import VelenAI
vai = VelenAI(api_key="your-key", api_secret="your-secret", host="http://localhost:8000")
Decorator (simplest)
@vai.track("my-agent")
def run_agent(query: str):
result = llm.chat(query)
return result
# Async works too
@vai.track("my-async-agent")
async def run_agent(query: str):
return await llm.chat(query)
Context Manager (more control)
with vai.trace("my-agent") as t:
result = do_work()
t.success = True
t.tokens = 150
t.cost_usd = 0.003
t.metadata["model"] = "gpt-4"
Manual
vai.emit(
agent_id="my-agent",
success=True,
latency_ms=1200,
tokens=150,
cost_usd=0.003,
metadata={"model": "gpt-4"},
)
Provider Wrappers
Auto-capture token usage, cost, and latency from cloud LLM providers:
from anthropic import Anthropic
from velenai.providers import wrap_anthropic
client = wrap_anthropic(Anthropic(), vai=vai)
# All API calls are now automatically tracked
response = client.messages.create(model="claude-sonnet-4-20250514", ...)
from openai import OpenAI
from velenai.providers import wrap_openai
client = wrap_openai(OpenAI(), vai=vai)
response = client.chat.completions.create(model="gpt-4o", ...)
Framework Adapters
CrewAI
from velenai_sdk import VelenAI
from velenai_sdk.adapters.crewai import VelenAICrewCallback
vai = VelenAI()
crew = Crew(
agents=[researcher, writer],
tasks=[research_task, write_task],
callbacks=[VelenAICrewCallback(vai)]
)
LangGraph
from velenai_sdk import VelenAI
from velenai_sdk.adapters.langgraph import instrument_graph
vai = VelenAI()
graph = StateGraph(...).compile()
graph = instrument_graph(vai, graph, agent_id="my-workflow")
result = graph.invoke(input)
Or as a LangChain callback:
from velenai_sdk.adapters.langgraph import VelenAILangGraphCallback
result = graph.invoke(input, config={"callbacks": [VelenAILangGraphCallback(vai)]})
AutoGen
from velenai_sdk import VelenAI
from velenai_sdk.adapters.autogen import instrument_agent
vai = VelenAI()
assistant = AssistantAgent("analyst", llm_config=llm_config)
assistant = instrument_agent(vai, assistant)
Environment Variables
Instead of passing keys to the constructor:
export VELENAI_API_KEY=your-key
export VELENAI_API_SECRET=your-secret
export VELENAI_HOST=http://localhost:8000
vai = VelenAI() # picks up from env
Features
- Sync and async support
- Background batching (events queued and flushed every 5s)
- HMAC-signed requests (replay-protected)
- Fire-and-forget (never blocks your agent)
- Framework adapters: CrewAI, LangGraph, AutoGen
- Zero dependencies beyond
httpx - Self-hosted
License
MIT
Project details
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 velenai-0.8.0.tar.gz.
File metadata
- Download URL: velenai-0.8.0.tar.gz
- Upload date:
- Size: 37.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dcbf46f2d6d63a66c4c9cdeba0b3f37f74660487f8ab5a9848e976a689b0cb27
|
|
| MD5 |
a8d3b943119846fa8cbc85cebb611c93
|
|
| BLAKE2b-256 |
b70e35512235ce79e5557698c393d68c247dc0203e7f9d7a1c7b59c3cbfe67d1
|
File details
Details for the file velenai-0.8.0-py3-none-any.whl.
File metadata
- Download URL: velenai-0.8.0-py3-none-any.whl
- Upload date:
- Size: 37.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a63b0608bfa63bae7a79f9a7f0cf830fbe79c47869b2b43f299fa6dc7c78f24
|
|
| MD5 |
86a7c37968ca3aa4f5d60fcadcfbdd95
|
|
| BLAKE2b-256 |
851d8ba590da7b841cfce85beaa01a7f93981cc10321ca004cfc6c30c79a3ea0
|