Skip to main content

Production-grade observability and governance SDK for AI agents

Project description

Viktron SDK

Framework-agnostic governance SDK for AI agents — policy enforcement, telemetry, and real-time observability for production AI systems.

Install

pip install viktron-sdk
# With optional provider extras:
pip install "viktron-sdk[openai]"
pip install "viktron-sdk[anthropic]"
pip install "viktron-sdk[langchain]"
pip install "viktron-sdk[all]"

Quick Start

One-line decorator instrumentation

import viktron_sdk

# Initialise once at startup
viktron_sdk.init(
    api_key="vk_live_...",
    agent_id="my-research-agent",
    display_name="Research Agent v2",
    framework="crewai",
    llm_provider="anthropic",
    llm_model="claude-3-sonnet",
)

# Works on both sync and async functions
@viktron_sdk.observe(as_type="tool", skip_args=["api_key"])
async def search_web(query: str, api_key: str):
    ...

@viktron_sdk.observe(as_type="llm")
def call_model(prompt: str):
    ...

# Flush before exit (atexit handler covers normal exits automatically)
viktron_sdk.force_flush()
# Or fully shut down the SDK:
viktron_sdk.stop_tracing()

Debug mode — see traces locally

Pass debug=True (or set VIKTRON_DEBUG=1) to print every trace to stderr as it happens — instant confirmation the SDK is wired up, no dashboard needed:

viktron_sdk.init(api_key="vk_live_...", debug=True)
[viktron] initialized — agent=my-research-agent -> https://api.viktron.ai
[viktron] llm_call model=gpt-4o in=150 out=75 cost=$0.0012 latency=320ms status=ok

Connect any agent with zero code — the Gateway

If your agent uses a custom transport the SDK can't auto-patch (or you just want zero code), point its LLM base_url at the Viktron gateway. Your provider key stays in Authorization (never stored); only your workspace key sits in the path:

export OPENAI_BASE_URL="https://api.viktron.ai/v/vk_live_xxx/openai/v1"
# keep the provider's normal path suffix (/v1 for OpenAI-wire)
# named upstreams: openai | anthropic | nous | openrouter | groq | together | deepseek
# or /passthrough to forward to any OpenAI/Anthropic/Gemini-compatible endpoint

observe shorthand types: "llm"llm_call, "tool"tool_call, "guardrail"guardrail_check, "agent"agent_response.

CLI

# Check configuration and API connectivity
viktron doctor

# Refresh cached pricing data
viktron pricing

Telemetry (send agent events to your Viktron dashboard)

from viktron_sdk import ViktronTelemetry

tel = ViktronTelemetry(api_key="vk_live_...", agent_slug="my-agent")

# Record a task
tel.record_task("task-123", status="completed", duration_ms=4200, cost_usd=0.003)

# Use a context-managed span
with tel.span("run_campaign") as span:
    span.set_attribute("platform", "meta")
    result = run_campaign()
    span.set_output(result)

tel.close()  # flush remaining events

Policy Guard (intercept LLM calls with governance rules)

import openai
from viktron_sdk import ViktronGuard

client = ViktronGuard.wrap(
    openai.OpenAI(),
    api_key="vk_live_...",
    agent_id="sales-agent-prod",
)

# All create() calls are now policy-checked
response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Hello"}],
)

Works with OpenAI (sync & async), Anthropic, Cohere, and any client with .create() / .generate() call patterns.

Framework Integrations

# LangChain
from viktron_sdk.integrations.langchain import ViktronCallbackHandler
handler = ViktronCallbackHandler(api_key="vk_live_...", agent_id="my-chain")

# CrewAI
from viktron_sdk.integrations.crewai import ViktronCrewAIObserver
observer = ViktronCrewAIObserver(api_key="vk_live_...", agent_id="my-crew")

# AutoGen
from viktron_sdk.integrations.autogen import ViktronAutoGenHook
hook = ViktronAutoGenHook(api_key="vk_live_...", agent_id="my-autogen")

API Keys

Generate your API key at app.viktron.ai → Settings → API Keys.

Keys prefixed vk_live_ are production; vk_test_ are for testing.

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 Distribution

viktron_sdk-0.5.0.tar.gz (6.1 MB view details)

Uploaded Source

Built Distribution

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

viktron_sdk-0.5.0-py3-none-any.whl (42.2 kB view details)

Uploaded Python 3

File details

Details for the file viktron_sdk-0.5.0.tar.gz.

File metadata

  • Download URL: viktron_sdk-0.5.0.tar.gz
  • Upload date:
  • Size: 6.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for viktron_sdk-0.5.0.tar.gz
Algorithm Hash digest
SHA256 1f1c121dda74d08ac206f5f7197221712fc2699a743495b45289a7f9b3783369
MD5 2e45638d4a3e68d69a685390b3149542
BLAKE2b-256 28b0d04dc8750688c2aec1e70cfb1c837350a36f91d75a03657f9e7ef6d44add

See more details on using hashes here.

File details

Details for the file viktron_sdk-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: viktron_sdk-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 42.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for viktron_sdk-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a4138b1c3a819c44080bb7b6c56664cb19327e46ca6bfc5b1bdbd684f60c9601
MD5 847aee6b77cbd241a1c505c13633fe59
BLAKE2b-256 6c87cb296569008d0b63ccd77884b9530e240712f8801a17c0591f0caaea0cfa

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