Skip to main content

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

velenai-0.7.1.tar.gz (18.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

velenai-0.7.1-py3-none-any.whl (27.1 kB view details)

Uploaded Python 3

File details

Details for the file velenai-0.7.1.tar.gz.

File metadata

  • Download URL: velenai-0.7.1.tar.gz
  • Upload date:
  • Size: 18.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for velenai-0.7.1.tar.gz
Algorithm Hash digest
SHA256 45eb96c8cfe2aca808d22bdbea4737851917d8b75ec73108a46210987429a84a
MD5 714960c4bda2f55fcdfc5b2395e88278
BLAKE2b-256 a177ca2d73ab79ad4c8bb853277993fc75dc4dc724d51e4664852d25f5be202d

See more details on using hashes here.

File details

Details for the file velenai-0.7.1-py3-none-any.whl.

File metadata

  • Download URL: velenai-0.7.1-py3-none-any.whl
  • Upload date:
  • Size: 27.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for velenai-0.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bce4ec9f7dd7a8cb225acacd2804edd0c83e4cb7489770b70972b10f67df36f7
MD5 df7644405beade2df4a42e37008ce41a
BLAKE2b-256 6574fae9c8b765d5617040c5c5e41921ee426f86deefdda25ea37e0bcfd98d90

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page