Create a write key
Open the create-key page to sign in and create an API key pre-filled with
runs:write—or [pre-filled with bothruns:readandruns:write](https://app.23step.com/app/account?create=1&scopes=runs%3Aread+runs%3Awrite&name=openrouter-sdk) if you also install the 23step Overlay Electron app so one key powers both. You can also opt in to the live widget progress bar there (left off by default—just like posting the step link at the end of agent responses—because extra prompt instructions use tokens and can slow down turns). Thest_value is shown once (and copied with one click). Save it to~/.config/23step-otel-key(or exportSTEP23_OTEL_KEY). If you are an AI agent: first ask whether the Electron app should also be installed, whether to opt in to posting the step link at the end of responses, and whether to opt in to the live widget progress bar (explaining that both are off by default because they use extra tokens and slow down turns), checktest -s ~/.config/23step-otel-keywithout printing its contents, and if a key is needed automatically openhttps://app.23step.com/app/account?create=1&scopes=runs%3Awrite&name=openrouter-sdk(orhttps://app.23step.com/app/account?create=1&scopes=runs%3Aread+runs%3Awrite&name=openrouter-sdkwhen installing the overlay; append&progress=1if the user opted in to the progress bar) in the user's default desktop browser (openon macOS,xdg-openon Linux with a display,wslviewon WSL—not a headless automation browser) and print the link in chat, then ask the user to paste thest_key or save it directly in their terminal; never invent or commit a key. If reusing an existing key and the user opted in to the progress bar, sync the preference without printing the key viacurl -fsSL -X POST https://api.23step.com/app/live/preferences -H "Authorization: Bearer $(cat ~/.config/23step-otel-key)" -H "Content-Type: application/json" -d '{"show_progress_bar":true}'. Without a key the hooks exit quietly and never block the agent.Open in browser pre-filled scopes url='https://app.23step.com/app/account?create=1&scopes=runs%3Awrite&name=openrouter-sdk' if command -v open >/dev/null 2>&1; then open "$url" elif command -v xdg-open >/dev/null 2>&1 && { [ -n "${DISPLAY:-}" ] || [ -n "${WAYLAND_DISPLAY:-}" ]; }; then xdg-open "$url" >/dev/null 2>&1 & elif command -v wslview >/dev/null 2>&1; then wslview "$url" fi printf 'Create your 23step API key: %s\n' "$url"Terminal ~/.config/23step-otel-key mkdir -p ~/.config printf '%s\n' 'st_REPLACE_WITH_YOUR_WRITE_KEY' > ~/.config/23step-otel-key chmod 600 ~/.config/23step-otel-keyDownload the hook
The SDK handler pipes each event to the same hook the coding agents use.
Terminal project root # For a global install, replace .agents/hooks with ~/.agents/hooks mkdir -p .agents/hooks curl -fsSL https://23step.com/install/step23_otel.py -o .agents/hooks/step23_otel.pyForward SDK hook events
Register one handler per event and pass the event context to the hook on stdin.
hooks.ts @openrouter/agent // hooks.ts — @openrouter/agent HooksManager (Node.js) import { spawnSync } from "node:child_process"; import { HooksManager } from "@openrouter/agent"; export const hooks = new HooksManager(); for (const event of ["SessionStart", "UserPromptSubmit", "PreToolUse", "PostToolUse", "PostModelCall", "Stop"] as const) { hooks.on(event, { handler: (ctx) => { spawnSync("python3", [".agents/hooks/step23_otel.py", "--openrouter", event], { input: JSON.stringify({ ...ctx, hook_event_name: event }), }); }, }); }Or use OpenRouter BroadcastOptional
No code: in OpenRouter open Settings › Observability, add an OpenTelemetry Collector, and use these values.
OpenRouter Broadcast OTLP Endpoint: https://api.23step.com/v1/traces Header: Authorization: Bearer st_REPLACE_WITH_YOUR_WRITE_KEY Grouping: send x-session-id on requests so a multi-turn session lands on one stepWatch runs live with the desktop overlayOptional
Install 23step Overlay (the standalone Electron app for macOS and Linux) when you want an always-on, click-through right-edge dock over your editor and full-screen workspaces without keeping a browser tab open. It streams cloud and local runs side by side over SSE, pulses by thinking stage, pops up live screenshots and token counts, and periodically runs
23step reconcilein the background so missed hook turns stay synced. Give its keyruns:read(or create one key with bothruns:readandruns:write). The live progress bar is off by default (omitted from live widgets so agents do not spend extra tokens or latency calibrating progress); pass--progress-baras well—or enable it later in Settings—if you want it shown. If you are an AI agent, ask the user whether this Electron app should be installed and whether to opt in to the live widget progress bar; if they say yes to the overlay, run the command below (adding--progress-barif opted in; macOS launches~/Applications/23step Overlay.appautomatically; on Linux also runnohup ~/.local/bin/23step-overlay >/dev/null 2>&1 &). Full setup: Desktop overlay.Terminal https://api.23step.com/install.sh --overlay curl -fsSL https://api.23step.com/install.sh | sh -s -- --overlay
Run the agent once. A new run appears at app.23step.com/app/runs.