Langfuse icon

Langfuse

Log LLM traces, spans, generations, and scores to Langfuse, or query traces, prompts, datasets, sessions, and more via the Public API.

Ingestion → Span Create

AI-generated

Summary

Create a new span observation in Langfuse's ingestion API, optionally linking it to an existing trace or parent observation and providing detailed contextual and timing information.

Inputs

  • name (required) — Human-readable name for the span to identify it within the trace.
  • traceId — Trace ID to associate the span with; leave blank to auto-fill from previous step or to start a new trace.
  • eventId — Optional event ID for idempotency and deduplication.
  • observationId — Optional override for the span's observation ID; blank to auto-generate a new ID.
  • parentObservationId — Optional parent observation ID to nest this span within another span, generation, event, or log.
  • timestamp — ISO 8601 timestamp for the span event; if omitted, the current time is used.
  • startTime — ISO 8601 start time for the span; defaults to the current time if not provided.
  • environment — Optional environment label such as 'production'.
  • inputJson — JSON string representing the input payload associated with this span.
  • outputJson — JSON string representing the output payload associated with this span.
  • metadataJson — Additional JSON metadata stored with the span observation.
  • version — Optional version string to label the span.
  • level — Optional observation level such as 'info'.
  • statusMessage — Optional status message for the span.
  • failOnBatchErrors — Boolean to indicate whether to fail the operation if Langfuse returns partial ingestion errors.

Output shape

a single record containing at least the generated or assigned 'traceId' and 'observationId' for the created span

The output includes the actual IDs used for the span and trace, which may be auto-generated if not provided, enabling subsequent operations to link to the same trace or span. Partial ingestion errors may be surfaced based on 'failOnBatchErrors' setting.

Links

Discussion