LedgeKitDocs
API referenceSwift SDK
Developer documentation

Recording values

Application context, native JSON, references, errors, and producer metadata.

LedgeRecording

public init(
    input: (any Encodable & Sendable)? = nil,
    promptTemplate: (any Encodable & Sendable)? = nil,
    outputReferences: [String: LedgeOutputReference]? = nil
)

Per-call context accepted by respond and startSpan. Input/template encoding happens at the recording boundary, before model execution. Encoding failures emit captureFailed and retain an explicit error marker. Later requests do not inherit previous annotations.

JSON and references

LedgeJSONValue is Codable, Equatable, and Sendable, with cases null, bool(Bool), integer(Int64), unsignedInteger(UInt64), number(Double), string(String), array([LedgeJSONValue]), and object([String: LedgeJSONValue]). Optional nil means absent; .null captures a JSON null.

LedgeOutputReference has .text(String) and .object([String: LedgeJSONValue]) cases and supports string literals. It enriches display without modifying native output.

Status and errors

LedgeStatus has running, success, failure, cancelled, and interrupted. Custom providers complete spans with a terminal status; .running does not complete a span. The HTTP API accepts finalized records only.

LedgeError(error) captures an error's type, domain, code, and message. LedgeDiagnostic and delivery summaries report telemetry problems separately.

Producer metadata

LedgeProducer.capture(serviceName:) captures serviceName, sdkVersion, app version/build, and OS name/version/build. It is Codable, Equatable, and Sendable. Its evaluationInfo supplies producer metadata when creating a native evaluation.

Envelope and transcript serialization types are internal. Custom transports receive encoded bytes; custom HTTP producers follow the trace envelope.

On this page