Skip to main content

API Surface

The TypeScript SDK exports the Observe class, function equivalents, and Beacon compatibility constants from @asymptote/sdk. For guided setup, start with SDK Quickstart, Instrumentation, Observe, and SDK Lifecycle.

Observe APIs

APIPurpose
Observe.initialize(options)Configure the OpenTelemetry provider, exporter, resource attributes, and default instrumentations
Observe.getTracer(name?, version?)Return the SDK tracer, or the global OpenTelemetry tracer before initialization
Observe.observe(options, fn)Wrap a sync, async, or async-iterable function in a span
Observe.patch(modules)Manually apply supported instrumentations to modules loaded before initialization
Observe.instrumentations(options?)Return OpenAI and Anthropic OpenLLMetry instrumentations for an existing provider
Observe.wrapClaudeAgentQuery(query)Wrap a Claude Agent SDK query function with a Beacon-compatible prompt span
Observe.flush()Force flush finished spans
Observe.shutdown()Disable instrumentations, shut down the provider, and allow later reinitialization
Function exports are also available for the same operations, including initialize, getTracer, observe, patch, initializeAsymptoteInstrumentations, wrapClaudeAgentQuery, flush, shutdown, isInitialized, and resolveExporterConfig.

Initialize Options

OptionPurpose
apiKeyAsymptote Managed hosted Observe API key. Defaults to ASYMPTOTE_API_KEY
baseUrlAsymptote Managed hosted Observe base URL. Defaults to ASYMPTOTE_BASE_URL or https://api.asymptotelabs.ai
otlpEndpointExplicit OTLP/HTTP endpoint. Defaults to OTEL_EXPORTER_OTLP_ENDPOINT
headersAdditional exporter headers
serviceNameOpenTelemetry service name. Defaults to OTEL_SERVICE_NAME or asymptote-app
resourceAttributesExtra OpenTelemetry resource attributes
instrumentModulesAlready-loaded modules to patch manually
disableInstrumentationsDisable default OpenAI and Anthropic instrumentations
instrumentationOptionsConfigure OpenAI and Anthropic instrumentation behavior
spanProcessor / spanProcessorsCustom span processors
spanExporterCustom span exporter
disableDefaultExporterSkip hosted or explicit OTLP exporter creation
disableBatchUse a simple span processor instead of batching
traceExportTimeoutMillisBatch exporter timeout
maxExportBatchSizeBatch exporter size limit
Observe.initialize() may only be called once per process configuration. Call Observe.shutdown() before reinitializing with different options. A later initialize({ instrumentModules }) call can patch additional modules without replacing the provider.

Observe Options

OptionPurpose
nameSpan name
spanKindOptional OpenTelemetry span kind
attributesSpan attributes, including Beacon compatibility attributes
ignoreInputDo not record asymptote.observe.input.count
ignoreOutputDo not record asymptote.observe.output.type

Export Modes

ModeHow it is selected
hostedAsymptote Managed apiKey or ASYMPTOTE_API_KEY is present and no explicit OTLP endpoint is configured
otlpotlpEndpoint or OTEL_EXPORTER_OTLP_ENDPOINT is present
customDefault exporter is disabled or a custom span exporter is provided

Beacon Compatibility Attributes

Cloud SDKs should prefer standard OpenTelemetry attributes when they exist, especially gen_ai.* attributes for model and prompt metadata. Use Beacon attributes for fields that need to normalize into Beacon endpoint-style events.
AttributePurpose
beacon.origincloud, local, or ci; the SDK sets cloud resource attributes by default
beacon.harness.nameRuntime or integration name such as vercel_ai_sdk, claude_agent_sdk, openai_sdk, anthropic_sdk, gemini_api, or custom_agent
beacon.event.actionNormalized action such as prompt.submitted, tool.invoked, command.executed, file.modified, mcp.tool_invoked, or approval.requested
beacon.event.categoryCategory such as prompt, tool, command, file, mcp, approval, or session
beacon.session.idStable trace, session, or conversation identifier
beacon.session.working_directoryWorkspace path when safe to disclose
beacon.tool.nameTool or function name
beacon.tool.commandTool arguments or command string, subject to redaction and size limits
beacon.tool.pathTool target path
beacon.commandShell command text
beacon.command.exit_codeShell command exit code
beacon.command.duration_msCommand duration in milliseconds
beacon.file.pathFile touched by the agent
beacon.file.operationFile operation such as read, create, modify, or delete
beacon.file.languageLanguage identifier
beacon.mcp.serverMCP server name
beacon.mcp.toolMCP tool name
beacon.approval.decisionApproval or policy decision
beacon.approval.reasonApproval or policy reason
beacon.prompt.textPrompt text when available
beacon.content.retentionContent retention hint

SDK Metadata Attributes

AttributePurpose
asymptote.observe.integration.nameIntegration or wrapper name
asymptote.observe.integration.versionIntegration package version
asymptote.observe.sdk.modeExport mode: hosted, otlp, or custom

Constants

The package exports constants for the stable Beacon event identity and compatibility attributes:
Import Beacon compatibility constants
import {
  ATTR_ASYMPTOTE_SDK_MODE,
  ATTR_BEACON_EVENT_ACTION,
  ATTR_BEACON_HARNESS_NAME,
  ATTR_BEACON_ORIGIN,
  BEACON_PRODUCT,
  BEACON_SCHEMA_VERSION,
  BEACON_VENDOR,
} from "@asymptote/sdk";
The wire-compatible Beacon event identity remains:
{
  "vendor": "beacon",
  "product": "endpoint-agent",
  "schema_version": "1.0"
}

Integration Pages

Anthropic

Instrument @anthropic-ai/sdk model calls.

Claude Agent SDK

Wrap Claude Agent SDK query functions.

OpenAI

Instrument openai package model calls.

Vercel AI SDK

Pass the Asymptote tracer into AI SDK telemetry.