Skip to main content
Replicas let you send every trace to multiple projects or workspaces at the same time. Where the dynamic routing patterns send each trace to one destination, replicas duplicate the trace to all configured destinations in parallel. Use replicas to:
  • Mirror production traces into a staging or personal project for debugging.
  • Write to multiple workspaces for multi-tenant isolation without changing any application code.
  • Send traces to the same server under different projects, with per-replica metadata overrides.

Configure replicas via environment variable

Set the LANGSMITH_RUNS_ENDPOINTS environment variable to a JSON value. Two formats are supported:
  • Object format: maps each endpoint URL to its API key. Each URL appears once, so use the array format when two replicas share a URL:
  • Array format: a list of replica objects, useful when you need multiple replicas pointing at the same URL or when you want to set a project_name per replica:
You cannot use LANGSMITH_RUNS_ENDPOINTS alongside LANGSMITH_ENDPOINT. If you set both, LangSmith raises an error. Use only one to configure your endpoint.

Configure replicas at runtime

You can also pass replicas directly in code, which is useful when destinations vary per request or tenant.
You can also use the updates field to merge additional fields (such as metadata or tags) into a run for a specific replica only, leaving the primary trace unchanged. Replica errors are non-fatal: if a replica endpoint is unavailable, LangSmith logs the error without affecting the primary trace.
Auth does not propagate in distributed traces. When a trace spans multiple services, LangSmith forwards replica project_name and updates to downstream services automatically, but not API keys or credentials. Each service must configure its own credentials for replica destinations.

Replicate within the same server (project-only replicas)

If all your replicas use the same LangSmith server, you can omit api_url and auth and specify only a project_name. The SDK reuses the default client credentials:

Leave feedback on all replica instances

When you use replicas, each replica receives a copy of every run. To submit feedback for a run on a specific replica, you need that replica’s run ID. In Python SDK 0.10.8 or later and JS SDK 0.8.5 or later, you can designate one replica as the primary and use compute_run_id_for_secondary_replica to deterministically calculate the run IDs for all other replicas. The primary replica keeps the original run ID unchanged. Each secondary replica receives a deterministic run ID derived from the original run ID and the secondary replica’s project name. Use compute_run_id_for_secondary_replica(original_run_id, project_name) to compute the secondary run ID and pass it when calling create_feedback. Both SDKs raise an error if the run ID is not a UUID v7, or if the project name is empty.
The compute_run_id_for_secondary_replica / computeRunIdForSecondaryReplica helper is available in Python SDK 0.10.8 or later and JS SDK 0.8.5 or later. If you are using an earlier SDK version, upgrade to use this feature.

Route between LangSmith and OpenTelemetry destinations

You can decide at runtime whether a given invocation sends traces to LangSmith, to an OpenTelemetry (OTel) backend, or to both, without redeploying or modifying application logic. This is useful when you want to toggle between observability backends per environment, or even per request, making the decision at runtime. Set the tracing mode using the tracing_mode constructor argument or the LANGSMITH_TRACING_MODE environment variable. Both accept the same values; an explicit tracing_mode argument always takes precedence over the env var:
  • "langsmith" (default): sends traces natively to LangSmith.
  • "otel": exports traces as OpenTelemetry spans to a configured OTel backend.
  • "hybrid" (Python only): sends to both LangSmith and an OTel backend from a single replica.
If you are using the deprecated otel_enabled parameter on Client (Python only), migrate to tracing_mode: Client(otel_enabled=True) → Client(tracing_mode="hybrid"). The otel_enabled parameter is removed in the next minor version.
Pass a configured Client directly into a replica to apply the desired mode at runtime:
The tracing_mode on each Client determines that replica’s export path. In Python, "hybrid" mode handles both destinations within a single replica. In TypeScript, the “send to both” case uses two separate replicas, one for each client, because there is no "hybrid" mode. Since each replica resolves its own client independently, you can also mix modes within a single tracing_context, for example keeping one replica sending to LangSmith while forwarding the same trace to an OTel collector via a second replica.