@withgateway/sdk package is the Node client for worlds and the runs made against them. Use it to open a live session and drive it from an agent, publish and pin a world’s versions, gate a pull request on a graded run, and trace what the agent did.
The package also installs the gateway command. Terminal usage is documented under The gateway CLI, not here.
Install the package
observeOpenAI or observeAnthropic needs nothing extra. The OpenInference instrumentation ships with the package as an optional dependency.
Set three environment variables
Every client reads the same three variables. Generate the key pair under Project Settings, API keys; the world, session or run you create lands in the project those keys belong to.gateway auth login writes the same three values to ~/.gateway/config.json for the CLI. The SDK reads the environment only, so a script still needs the variables exported.
Keep the secret key in environment variables or a secrets manager. Never hardcode it in source files, examples, or agent prompts.
{ host, publicKey, secretKey } object as its last argument when one call needs different credentials than the environment holds.
Open a world session and call it
openWorld resolves a slug to its pinned version and task list. open boots a live container for one task, and toolkit() hands you that world’s tools in the shape a model expects.
schemas to your model as its tool definitions and dispatch tool calls through impls. Nothing else in the agent has to know a world exists.
The TypeScript SDK resolves versions, drives hosted sessions, and dispatches hosted runs. To run a world in your own process, use the Python SDK.
The import map
The root entry re-exports the worlds, sessions, replay, scores, users, experiments, context, memory, personas and security modules, plus
identify and the build manifest helpers. Importing a subpath keeps a service’s dependency surface smaller; the examples in this section use subpaths.
tracing.init() imported from @withgateway/sdk also wires experiment attributes onto every span. Imported from @withgateway/sdk/tracing it does not. Use the root entry when the same process assigns variants and traces.Where to go next
- Worlds for resolving a version and dispatching a hosted run.
- World sessions for every method on a live session.
- Run a task suite for running a dozen tasks in parallel with a score gate.
- Gate a pull request for
validateWorldin GitHub Actions. - The gateway CLI for the same operations from a terminal.