Skip to content

Environment Variables

Node.js

@pydantic/logfire-node reads these variables:

VariablePurpose
LOGFIRE_TOKENWrite token used to send traces, metrics, and logs to Logfire.
LOGFIRE_API_KEYAPI key for platform APIs such as remote managed variables.
LOGFIRE_SERVICE_NAMEService name resource metadata.
LOGFIRE_SERVICE_VERSIONService version resource metadata.
LOGFIRE_ENVIRONMENTDeployment environment resource metadata.
LOGFIRE_CONSOLESet to true to also print spans to the console. Boolean-only.
LOGFIRE_MIN_LEVELMinimum manual Logfire level to emit.
LOGFIRE_SEND_TO_LOGFIRESet sending behavior. if-token-present sends only when a token exists.
LOGFIRE_DISTRIBUTED_TRACINGSet to false to suppress extraction of incoming trace context.
LOGFIRE_TRACE_SAMPLE_RATEHead sampling rate from 0 to 1.
LOGFIRE_BASE_URLOverride the Logfire API base URL.
LOGFIRE_CREDENTIALS_DIRDirectory containing logfire_credentials.json for local Node projects.
OTEL_SERVICE_NAMEService name fallback when LOGFIRE_SERVICE_NAME is unset.
OTEL_SERVICE_VERSIONService version fallback when LOGFIRE_SERVICE_VERSION is unset.

For service metadata, precedence is code configuration, then LOGFIRE_*, then OTEL_*.

LOGFIRE_MIN_LEVEL accepts trace, debug, info, notice, warning, error, or fatal. Values are matched case-insensitively. Numeric strings are not accepted. Invalid values warn with console.warn and are ignored.

LOGFIRE_CONSOLE=true enables Node console output with the default console minimum level of info. Object-style console options such as console.minLevel, console.includeTags, and console.includeTimestamps are available only through code configuration.

When LOGFIRE_TOKEN is unset and no code token is passed, Node.js also checks for .logfire/logfire_credentials.json in the current working directory. LOGFIRE_CREDENTIALS_DIR changes that directory. These local credentials are written by npx logfire projects use/new and are not read by browser code.

Cloudflare Workers

@pydantic/logfire-cf-workers reads Worker environment values:

VariablePurpose
LOGFIRE_TOKENWrite token used by the Worker exporter.
LOGFIRE_ENVIRONMENTDeployment environment metadata.
LOGFIRE_BASE_URLOverride the Logfire API base URL.

Store production values as Worker secrets.

Browser

@pydantic/logfire-browser does not read Logfire credentials from environment variables. Configure a traceUrl that points at your backend proxy.

Generic OpenTelemetry

Platforms such as Deno and Vercel’s OpenTelemetry integration use standard OTLP environment variables:

VariablePurpose
OTEL_EXPORTER_OTLP_ENDPOINTBase OTLP endpoint, such as https://logfire-api.pydantic.dev.
OTEL_EXPORTER_OTLP_TRACES_ENDPOINTTrace endpoint, such as https://logfire-api.pydantic.dev/v1/traces.
OTEL_EXPORTER_OTLP_METRICS_ENDPOINTMetric endpoint, such as https://logfire-api.pydantic.dev/v1/metrics.
OTEL_EXPORTER_OTLP_HEADERSHeaders for OTLP export, including Authorization=your-write-token.