Skip to main content

LlamaIndex callback handler for NeBeso AI cost tracking

Project description

llama-index-callbacks-nebeso

LlamaIndex callback handler for NeBeso — open source AI cost tracking.

Track every LLM call in your LlamaIndex app: tokens, cost, latency, and custom tags — all visible in your NeBeso dashboard in real time.

Installation

pip install llama-index-callbacks-nebeso

Quick start

from llama_index_callbacks_nebeso import NeBesoHandler
from llama_index.core import Settings
from llama_index.core.callbacks import CallbackManager

handler = NeBesoHandler(
    api_key="nb_ak_...",          # or set NEBESO_API_KEY env var
    tags={"feature": "rag-search", "env": "production"},
)
Settings.callback_manager = CallbackManager([handler])

# Now build your index and query normally — all LLM calls are tracked.

Usage with RAG pipelines

from llama_index_callbacks_nebeso import NeBesoHandler
from llama_index.core import VectorStoreIndex, SimpleDirectoryReader, Settings
from llama_index.core.callbacks import CallbackManager

handler = NeBesoHandler(api_key="nb_ak_...")
Settings.callback_manager = CallbackManager([handler])

documents = SimpleDirectoryReader("data").load_data()
index = VectorStoreIndex.from_documents(documents)

query_engine = index.as_query_engine()
response = query_engine.query("What are the main topics?")
# Token usage and cost are now visible in your NeBeso dashboard.

Supported providers

Works with any LlamaIndex-supported LLM: OpenAI, Anthropic, Google Gemini, Mistral, Meta Llama, Cohere, AWS Bedrock, and more. Cost is calculated automatically from a built-in pricing table covering 60+ models.

Environment variables

Variable Description
NEBESO_API_KEY Your NeBeso API key (alternative to api_key= kwarg)
NEBESO_ENDPOINT Override API endpoint (default: https://api.nebeso.com)

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

llama_index_callbacks_nebeso-0.1.0-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file llama_index_callbacks_nebeso-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for llama_index_callbacks_nebeso-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 94a008b293dfa400b90be7a390d45f4261d03339ac155242e038eb31ed741fa8
MD5 d5b33574002a14948208d04e097666a9
BLAKE2b-256 3a8db252b66d7577658a2b4f1458853e81f5aa7bc7bebb748277ebc005b5f931

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