@withgateway/sdk/scores sends both. The shape matches the Python SDK’s Run.score() and Run.success() exactly, so signals from either client aggregate together without change.
This subpath needs @opentelemetry/api installed, because it reads the active span to find the trace a score belongs to.
Create a client
fromEnv(config?) reads GATEWAY_HOST, GATEWAY_PUBLIC_KEY and GATEWAY_SECRET_KEY, and throws ScoreError naming what is missing. Any field passed in config wins over the environment, and timeoutSeconds defaults to 15.
Post a score
A score targets exactly one of a session, a dataset run, or a trace, in that order of preference. With no target given and no active span, the call is a no-op rather than an error.
score() and success() are fail-soft. A broken transport warns and resolves rather than throwing into your agent. Use postScore() with the same arguments when you want the failure.Emit a success signal
success(name, value?, options?) records a score tagged as an aggregatable signal. A boolean value records a pass or fail, and a number records a measurement.
value defaults to true. success takes every score option plus two of its own.
The signal keys are written last, so your own
metadata cannot overwrite them and drop the signal from aggregation.
Emit one whenever a real unit of value happens: a ticket resolved, an eval run, a human accepting an edit.
Score the trace you are already in
With tracing initialized and a span open, omit the target and the active trace is used.currentTraceId() returns the active trace id, or undefined when there is no valid active span.
Score into an isolated project
A handle fromtracing.initIsolated() carries a scores client bound to that handle’s keys. Its signals land in the same project the handle’s spans export to, with no credentials threaded through your own code.
Where to go next
- Evaluation and Replay for how scores show up on the platform.
- Runs and Scoring for the Python equivalents.
- Tracing and experiments for the traces these scores attach to.