Coding agents

Set up 23step for OpenRouter SDK

Record agents you build with the OpenRouter Agent SDK, or any OpenRouter traffic via Broadcast.

Markdown for AIAll install methods
  1. 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 both runs:read and runs: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). The st_ value is shown once (and copied with one click). Save it to ~/.config/23step-otel-key (or export STEP23_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), check test -s ~/.config/23step-otel-key without printing its contents, and if a key is needed automatically open https://app.23step.com/app/account?create=1&scopes=runs%3Awrite&name=openrouter-sdk (or https://app.23step.com/app/account?create=1&scopes=runs%3Aread+runs%3Awrite&name=openrouter-sdk when installing the overlay; append &progress=1 if the user opted in to the progress bar) in the user's default desktop browser (open on macOS, xdg-open on Linux with a display, wslview on WSL—not a headless automation browser) and print the link in chat, then ask the user to paste the st_ 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 via curl -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 create-key page

    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-key
  2. Download 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.py
  3. Forward 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 }),
          });
        },
      });
    }
  4. 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 step
  5. Watch 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 reconcile in the background so missed hook turns stay synced. Give its key runs:read (or create one key with both runs:read and runs: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-bar as 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-bar if opted in; macOS launches ~/Applications/23step Overlay.app automatically; on Linux also run nohup ~/.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
Check that it worked

Run the agent once. A new run appears at app.23step.com/app/runs.