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.
| Provider | grad sources add | Feedback it brings in |
|---|---|---|
| Langfuse | langfuse | Scores |
| LangSmith | langsmith | Feedback, including corrections |
| Braintrust | braintrust | Scores and expected answers |
| PostHog | posthog | Survey responses tied by $ai_trace_id |
| Arize Phoenix | phoenix | Span annotations |
| Gradiated Cloud gateway (coming soon) | gradiated | Requests 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:
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#
- Tag each trace with the model and version that produced it.
- Send feedback to the same tool when you learn the outcome: a thumbs up, a test result, a human fix.
- Store the tool's API key with
grad secrets set NAME(orclient.secrets.set(name, value)) and add a source withgrad sources add. A source feeds one dataset; a dataset can have several sources, one per provider or project. - 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:
| Filter | Value | A trace matches when |
|---|---|---|
tags | a list | it carries every tag |
environment, model, version, release, name, user_id, session_id | a string or a list | it has one of the values (name is the trace or route) |
metadata | {key: value} | each key equals its value |
from, to | ISO 8601 times | it started in [from, to) |
has_feedback | true | it has a score or a correction |
min_score | a 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.
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.