SynaptraDocs

    Getting started

    Quickstart

    Create a harness, register how it's scored, report a baseline, run your first experiment and adopt it. About 20 minutes, in Python or TypeScript.

    #

    Before you start

    • A Synaptra account: sign up with your email.
    • An evaluation you can run: a set of inputs with expected outputs, and a way to score one output.
    • An API token: in the app, Connect → API tokens → Make token. Keep it in SYNAPTRA_TOKEN.
    #

    1. Install and connect

    Terminal
    pip install synaptra-sdk
    export SYNAPTRA_TOKEN=syn_...   # from Connect → API tokens
    Terminal
    npm install synaptra-sdk
    export SYNAPTRA_TOKEN=syn_...   # from Connect → API tokens

    The Python client uses only the standard library and the TypeScript client has no dependencies, so both run on bare remote boxes. The TypeScript one also runs on Bun, Deno, Cloudflare Workers and in browsers: see where it runs.

    #

    2. Create a harness

    create.py
    import os
    from synaptra_sdk import Harness
    
    h = Harness.create(
        "Support bot",
        objective="Resolve tickets on the first reply",
        metric="accuracy", direction="max", bar=0.8,
        template="llm_agent",
        url="https://synaptra.my", token=os.environ["SYNAPTRA_TOKEN"],
    )
    print(h.id, h.next_step)
    create.ts
    import { Harness } from "synaptra-sdk";
    
    const h = await Harness.create({
      name: "Support bot",
      objective: "Resolve tickets on the first reply",
      metric: "accuracy", direction: "max", bar: 0.8,
      template: "llm_agent",
      url: "https://synaptra.my", token: process.env.SYNAPTRA_TOKEN,
    });
    console.log(h.id, await h.nextStep);

    direction: "max" means higher is better; use "min" for latency or error rates. The template picks the starting ladder: harness (the default), llm_agent for prompt, tool and model changes, or pipeline for step settings. See Harnesses.

    #

    3. Register tools and hooks

    register.py
    @h.tool(description="Search the help centre")
    def kb_search(query: str, k: int = 5) -> list:
        ...                                   # your code; Synaptra keeps the schema
    
    @h.scorer
    def exact(output: str, expected: str) -> float:
        return float(output.strip() == expected.strip())
    
    h.dataset("golden", path="s3://my-bucket/golden.jsonl", size=500)
    h.runner("python eval.py --variant {variant} --tier {tier}")
    print(h.readiness)
    register.ts
    await h.tool(
      {
        name: "kb_search",
        description: "Search the help centre",
        schema: {
          type: "object",
          properties: { query: { type: "string" }, k: { type: "integer", default: 5 } },
          required: ["query"],
        },
      },
      kbSearch,                               // your code; Synaptra keeps the schema
    );
    
    const exact = ({ output, expected }: { output: string; expected: string }) =>
      Number(output.trim() === expected.trim());
    await h.scorer({ name: "exact" }, exact);
    
    await h.dataset("golden", { path: "s3://my-bucket/golden.jsonl", size: 500 });
    await h.runner("node eval.js --variant {variant} --tier {tier}");
    console.log(await h.readiness);

    Action tools are what your agent calls; the scorer, dataset and runner are evaluation hooks. Synaptra records them (names, schemas, the run command, the dataset's location, size and fingerprint) and never runs them. In Python the schema comes from the function's signature; in TypeScript you pass it, as JSON Schema or Zod. See Tools and evaluation hooks.

    #

    4. Report a baseline

    baseline.py
    rows = []
    for task in smoke_tasks:                 # a handful of examples
        out = my_agent(task.input)           # runs on your machine
        rows.append({"task": task.id, "metrics": {"accuracy": exact(out, task.expected)}})
    print(h.report(rows, variant="base", tier="T0"))
    baseline.ts
    const rows = [];
    for (const task of smokeTasks) {          // a handful of examples
      const output = await myAgent(task.input); // runs on your machine
      rows.push({ task: task.id, metrics: { accuracy: exact({ output, expected: task.expected }) } });
    }
    console.log(await h.report(rows, { variant: "base", tier: "T0" }));

    Then the same on the dev set (tier T1). Your harness now knows what it has to beat.

    #

    5. Run an experiment

    Write down the change and what you expect it to score on each tier before it runs. Then ask the gate before each tier, run the variant with your runner, and report its rows into the experiment.

    experiment.py
    e = h.propose("Shorter system prompt", "prompt-v2",
                  {"T0": {"pass_rate": 1.0}, "T1": {"mean_accuracy": 0.83}},
                  hypothesis="Less instruction noise, same coverage")
    
    gate = h.gate("prompt-v2", "T1", experiment_id=e["id"])
    print(gate["allowed"], gate.get("reasons"), gate.get("estimated_cost_usd"))
    
    h.report(run_variant("prompt-v2", "T1"), experiment_id=e["id"],
             variant="prompt-v2", tier="T1")
    experiment.ts
    const e = await h.propose({
      title: "Shorter system prompt",
      variant: "prompt-v2",
      hypothesis: "Less instruction noise, same coverage",
      predictions: { T0: { pass_rate: 1.0 }, T1: { mean_accuracy: 0.83 } },
    });
    
    const gate = await h.gate({ variant: "prompt-v2", tier: "T1", experimentId: e.id });
    console.log(gate.allowed, gate.reasons, gate.estimated_cost_usd);
    
    await h.report(await runVariant("prompt-v2", "T1"), { experimentId: e.id, variant: "prompt-v2", tier: "T1" });
    Terminal
    curl https://synaptra.my/api/harnesses/support-bot/experiments \
      -H "Authorization: Bearer $SYNAPTRA_TOKEN" -H "Content-Type: application/json" \
      -d '{"title": "Shorter system prompt", "variant": "prompt-v2",
           "hypothesis": "Less instruction noise, same coverage",
           "predictions": {"T0": {"pass_rate": 1.0}, "T1": {"mean_accuracy": 0.83}}}'

    The hypothesis is required. A gate refusal is an answer, not an error: it says why (for example, the cheaper tier isn't passed yet).

    #

    6. Close and adopt

    close.py
    out = h.close(e["id"], "adopt", note="Passed T1 and the held-out test set",
                  variant="prompt-v2")
    print(out["harness_version"])
    print(h.export()["format"])          # synaptra.harness/1, yours to keep
    close.ts
    const { harnessVersion } = await h.close({
      experimentId: e.id, decision: "adopt", variant: "prompt-v2",
      note: "Passed T1 and the held-out test set",
    });
    console.log(harnessVersion);
    console.log((await h.export()).format);   // synaptra.harness/1, yours to keep
    Terminal
    curl https://synaptra.my/api/experiments/42/close \
      -H "Authorization: Bearer $SYNAPTRA_TOKEN" -H "Content-Type: application/json" \
      -d '{"decision": "adopt", "variant": "prompt-v2", "note": "Passed T1 and the held-out test set"}'

    A note saying why is required. Adopting needs the variant to pass its gate, including the held-out test set, even if it only ran the cheaper tiers. If it passed, adopting makes version 2 of your harness, with the experiment, results and spec recorded. If it didn't, the close is refused (409 GATE, raised as GateRefused) with the reasons. You can adopt anyway with a written override reason; it's logged and shown on the version.

    #

    Next

    Something unclear or missing? Email support@synaptra.my.