Instrumentation SDK for Beacon — Chrome DevTools for AI Agents
Project description
beacon-sdk
Instrumentation SDK for Beacon.
Add tracing to Python agents with minimal changes and inspect traces in Beacon UI.
Quickstart
pip install beacon-sdk[openai]
import beacon_sdk
from openai import OpenAI
beacon_sdk.init()
client = OpenAI()
@beacon_sdk.observe
def run_agent(question: str) -> str:
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": question}],
)
return response.choices[0].message.content or ""
run_agent("What is the capital of France?")
Start Beacon (make dev) and open http://localhost:5173.
Integrations
| Integration | Behavior |
|---|---|
| OpenAI | auto-patched chat completions (sync/async + streaming + tool calls) |
| Anthropic | auto-patched messages (sync/async + streaming + tool use) |
| Google Gemini | auto-patched generate_content (sync/async + streaming) |
| CrewAI | auto-patched Crew.kickoff() with callback injection |
| AutoGen | auto-patched ConversableAgent.generate_reply() and GroupChat.run() |
| LlamaIndex | auto-patched BaseQueryEngine.query() and BaseRetriever.retrieve() |
| Ollama | auto-patched chat() and generate() (native client) |
| LiveKit Agents | auto-patched AgentSession voice lifecycle + key session events |
| Playwright | auto-patched page actions |
| subprocess | auto-patched run and check_output |
| LangChain | callback handler (BeaconCallbackHandler) |
File operation patching (builtins.open) is opt-in via BEACON_PATCH_FILE_OPS=true.
Install Extras
pip install beacon-sdk
pip install beacon-sdk[openai]
pip install beacon-sdk[anthropic]
pip install beacon-sdk[playwright]
pip install beacon-sdk[livekit]
pip install beacon-sdk[all]
Configuration
| Env var | Default | Meaning |
|---|---|---|
BEACON_BACKEND_URL |
http://localhost:7474 |
backend ingestion URL |
BEACON_ENABLED |
true |
enable/disable tracing |
BEACON_AUTO_PATCH |
true |
enable/disable auto-patching |
BEACON_LOG_LEVEL |
WARNING |
SDK logging level |
BEACON_PATCH_FILE_OPS |
false |
enable file operation patch |
init() options:
beacon_sdk.init(
backend_url="http://localhost:7474",
auto_patch=True,
enabled=True,
exporter="auto", # auto | async | sync
)
Public API
init()observeget_current_span()get_tracer()flush()shutdown()Span,SpanType,SpanStatus,BeaconTracer
OTLP Ingestion (SDK-Free)
Beacon accepts traces in standard OpenTelemetry Protocol (OTLP) JSON format. This lets you send traces from any OTEL-instrumented application without installing the Beacon SDK.
Endpoint: POST /v1/otlp/traces
Example payload:
{
"resourceSpans": [
{
"resource": {
"attributes": [
{ "key": "service.name", "value": { "stringValue": "my-agent" } }
]
},
"scopeSpans": [
{
"scope": { "name": "my-instrumentation", "version": "1.0.0" },
"spans": [
{
"traceId": "abc123",
"spanId": "span001",
"name": "llm_call",
"kind": 1,
"startTimeUnixNano": "1700000000000000000",
"endTimeUnixNano": "1700000001500000000",
"attributes": [
{ "key": "span_type", "value": { "stringValue": "llm_call" } },
{ "key": "llm.model", "value": { "stringValue": "gpt-4o" } },
{ "key": "llm.tokens.total", "value": { "intValue": "1500" } },
{ "key": "llm.cost_usd", "value": { "doubleValue": 0.023 } }
],
"status": { "code": 1 }
}
]
}
]
}
]
}
curl example:
curl -X POST http://localhost:7474/v1/otlp/traces \
-H "Content-Type: application/json" \
-d '{
"resourceSpans": [{
"scopeSpans": [{
"spans": [{
"traceId": "test-trace-001",
"spanId": "test-span-001",
"name": "my-llm-call",
"startTimeUnixNano": "1700000000000000000",
"endTimeUnixNano": "1700000001000000000",
"attributes": [
{"key": "span_type", "value": {"stringValue": "llm_call"}},
{"key": "llm.model", "value": {"stringValue": "gpt-4o"}}
],
"status": {"code": 1}
}]
}]
}]
}'
Response: { "accepted": 1, "rejected": 0 }
Attribute value types: stringValue, intValue, doubleValue, boolValue, arrayValue
Status codes: 0 = Unset, 1 = OK, 2 = Error
Valid span_type values: llm_call, tool_use, agent_step, shell_command, browser_action, custom (default)
Project details
Release history Release notifications | RSS feed
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 beacon_sdk-0.1.0.tar.gz.
File metadata
- Download URL: beacon_sdk-0.1.0.tar.gz
- Upload date:
- Size: 65.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9cd9cd3f6950199a5cc8fe314b5b804281b35137a6b4e974109ed4266fee3e3d
|
|
| MD5 |
05cdb4c017aa875016fd7a5a73a48088
|
|
| BLAKE2b-256 |
88ee383345e8046daf39497fbfd5cdd373bee98a36bb25acba1e29c598188dd0
|
Provenance
The following attestation bundles were made for beacon_sdk-0.1.0.tar.gz:
Publisher:
publish-sdk.yml on vexorlabs/beacon
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
beacon_sdk-0.1.0.tar.gz -
Subject digest:
9cd9cd3f6950199a5cc8fe314b5b804281b35137a6b4e974109ed4266fee3e3d - Sigstore transparency entry: 1001362901
- Sigstore integration time:
-
Permalink:
vexorlabs/beacon@83d0bbe65b3d0eae9863e2ed81580e2b0ecd41be -
Branch / Tag:
refs/tags/sdk-v0.1.0 - Owner: https://github.com/vexorlabs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-sdk.yml@83d0bbe65b3d0eae9863e2ed81580e2b0ecd41be -
Trigger Event:
push
-
Statement type:
File details
Details for the file beacon_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: beacon_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 38.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b4781f5b4a9d2987a898abb827b99d5504640490202acd9a5ea37f4a847cccf
|
|
| MD5 |
60741b6ca457b550ca9614c730e54d00
|
|
| BLAKE2b-256 |
324084bd78b48014634282b9e3d7f7ead87a3ce92bb90b20ff1ab576a5047806
|
Provenance
The following attestation bundles were made for beacon_sdk-0.1.0-py3-none-any.whl:
Publisher:
publish-sdk.yml on vexorlabs/beacon
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
beacon_sdk-0.1.0-py3-none-any.whl -
Subject digest:
3b4781f5b4a9d2987a898abb827b99d5504640490202acd9a5ea37f4a847cccf - Sigstore transparency entry: 1001362920
- Sigstore integration time:
-
Permalink:
vexorlabs/beacon@83d0bbe65b3d0eae9863e2ed81580e2b0ecd41be -
Branch / Tag:
refs/tags/sdk-v0.1.0 - Owner: https://github.com/vexorlabs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-sdk.yml@83d0bbe65b3d0eae9863e2ed81580e2b0ecd41be -
Trigger Event:
push
-
Statement type: