Silvanexumdocs

CrewAI

Meter and attribute a CrewAI crew's spend through the Silvanexum gateway.

CrewAI orchestrates multiple role-playing agents. Silvanexum captures the spend of a whole crew without changing your tasks: give each agent's LLM the Silvanexum gateway base URL, and every model call across the crew is metered on your own key, attributed, and budgeted — with a shared trace header so the multi-agent kickoff stitches into one attributed trace.

The gateway is OpenAI-compatible (/gateway/openai/v1) — use an OpenAI model and make sure your org has an OpenAI provider key saved (Settings → Keys). Your key needs the run scope.

Install

pip install silvanexum crewai

Point the crew's LLM at the gateway

import os
from silvanexum import Silvanexum
from crewai import Agent, Task, Crew, LLM
 
sx = Silvanexum()  # reads SILVANEXUM_API_KEY
 
llm = LLM(
    model="openai/gpt-4.1",
    base_url=sx.gateway.openai_base_url(),        # https://api.silvanexum.com/gateway/openai/v1
    api_key=os.environ["SILVANEXUM_API_KEY"],      # your Silvanexum key
    extra_headers={"x-silvanexum-trace": "research-crew"},
)
 
researcher = Agent(role="Researcher", goal="Find the key facts",
                   backstory="Meticulous analyst.", llm=llm)
task = Task(description="Summarize the latest on long-context models.",
            expected_output="Three bullet points.", agent=researcher)
 
crew = Crew(agents=[researcher], tasks=[task])
print(crew.kickoff())

Every agent's model call is metered on your BYO key — no separate capture call, no double spend.

See the spend

print(sx.gateway.usage().totals)   # 30-day totals + recent calls

Gateway spend counts toward your org budgets; a block-mode budget rejects an over-cap call with 402 before it bills.

Next steps

On this page