Integrations

Keep a dataset in sync with the traces and feedback in your observability tool.

A source connects a Dataset to a tracing tool. On a schedule (or when you ask), grad pulls new traces and the latest scores and corrections on them, and saves the result as a new dataset version. Your app keeps logging and collecting feedback with the tool's own SDK; grad never needs a feedback API of its own.

Providergrad sources addFeedback it brings in
LangfuselangfuseScores
LangSmithlangsmithFeedback, including corrections
BraintrustbraintrustScores and expected answers
PostHogposthogSurvey responses tied by $ai_trace_id
Arize PhoenixphoenixSpan annotations
Gradiated Cloud gateway (coming soon)gradiatedRequests and feedback recorded by the gateway

On Gradiated Cloud#

If your app calls models through the Gradiated gateway, the gateway records every request and its feedback, so you don't need an observability tool. Connect them with the built-in gradiated source; it needs no host or secret:

Shell
grad sources add gradiated --dataset support-prod --schedule "0 * * * *"

Self-hosted servers don't have the gateway, so the gradiated source is Cloud-only.

How it fits together#

  1. Tag each trace with the model and version that produced it.
  2. Send feedback to the same tool when you learn the outcome: a thumbs up, a test result, a human fix.
  3. Store the tool's API key with grad secrets set NAME (or client.secrets.set(name, value)) and add a source with grad sources add. A source feeds one dataset; a dataset can have several sources, one per provider or project.
  4. Syncs add new dataset versions with the latest scores (a scheduled sync at most every 15 minutes; see Versions). Runs pin a version, so retraining on newer feedback never changes an old run.

Deleting a dataset deletes its sources. A source syncs at most once a minute. If syncs keep failing (a revoked key, say), the source backs off and, after 10 failures in a row, pauses; grad sources list shows its status and last error, and grad sources sync ID or a new value for its secret resumes it. See When a sync fails.

A one-off file import is a snapshot and never gets later feedback; see Import from files.

Choose which traces sync#

A busy app logs far more than you want to train on. Narrow a source with filters, keep a share of traces with sample_rate, and cap how many new traces it takes:

FilterValueA trace matches when
tagsa listit carries every tag
environment, model, version, release, name, user_id, session_ida string or a listit has one of the values (name is the trace or route)
metadata{key: value}each key equals its value
from, toISO 8601 timesit started in [from, to)
has_feedbacktrueit has a score or a correction
min_scorea number, or {name: number}every score (or each named score) is at least that

A trace must match every filter you set. LangSmith also takes filter, a LangSmith filter expression that is ANDed with the rest. Any other key is a 422 source_filter_unsupported, so a typo never silently syncs everything. grad sends each filter its provider's API supports with the request (each provider page lists which) and applies the rest to what it fetched.

Feedback usually arrives after the trace, so has_feedback and min_score are checked on the merged dataset: a trace is stored when it syncs, and dataset reads and training see it once its scores pass.

sample_rate (between 0 and 1) keeps that share of traces, chosen by a hash of the trace ID: a re-sync keeps the same sample, and a trace's later feedback follows it. max_records_per_sync and max_records_per_day (a UTC day) cap the new traces a source takes; the rest aren't synced, and the sync's drop_reasons count them. Feedback on traces already synced always lands.

Shell
grad sources add langfuse \
  --dataset support-prod \
  --secret langfuse-prod \
  --schedule "* * * * *" \
  --filter environment=production \
  --filter 'min_score={"resolved": 1}' \
  --sample-rate 0.1 \
  --max-records-per-day 100000

grad sources show src_01J9X
grad sources update src_01J9X --filter environment=production --filter 'tags=["support"]' --max-records-per-day 0

The source shows the effective filters (single values become lists), its sample rate and caps, and records_today. An update applies from the next sync; filters replaces them all ({} clears them) and null removes a cap. Traces already synced stay; grad sources sync ID --full rebuilds the dataset with the new settings.

Versions#

A scheduled sync can run every minute, but it adds a dataset version at most every version_interval seconds (default 900; 0 makes every sync a version). Until then what it fetched waits, staged, and the source shows pending_records; the next version takes it all, in order, and a sync that finds nothing new adds no version. A version also comes as soon as 100,000 records wait. The first sync, a sync you start yourself and a full sync always add a version at once, and removing a source turns what waits into a last version. Set it with version_interval (--version-interval on the CLI) when you add or update a source.