TelemetrySettings

What the SDK records about a run, and where it sends it.

Turns on tracing for a call: spans for each step, tool execution, and model request, with token counts attached. Off by default, because recording prompts and completions is a decision about user data, not a default.

Enable it per call or per agent. Recording of prompt and completion text is a separate switch from recording the spans themselves.

let result = try await generateText(
  model: AnthropicModel("claude-sonnet-5"),
  prompt: prompt,
  telemetry: TelemetrySettings(isEnabled: true, functionID: "summarise")
)

Declaration

public struct TelemetrySettings

Defined in Sources/AI/Core/RuntimeContext.swift.

Initializer

init(
    isEnabled: Bool = true,
    functionID: String? = nil,
    metadata: [String: JSONValue] = [:],
    includeRuntimeContext: [String]? = nil,
    includeToolsContext: [String]? = nil
)

Properties

PropertyTypeDefault
var isEnabledBool
var functionIDString?
var metadata[String: JSONValue]
var includeRuntimeContext[String]?
var includeToolsContext[String]?

See also