> ## Documentation Index
> Fetch the complete documentation index at: https://docs.9thprotocol.com/llms.txt
> Use this file to discover all available pages before exploring further.

# SDK

> Programmatic access to the 9th Protocol agent.

<Warning>
  **Not yet available.** `@9thprotocol/sdk` currently ships types only — the
  runtime is not implemented. This page documents the intended shape so you can
  plan against it, but nothing here works today. Until it lands, drive the
  [CLI](/cli) programmatically instead.
</Warning>

## Intended shape

`@9thprotocol/sdk` will be MIT-licensed and expose the agent loop as an async
iterator of events:

```ts theme={null}
import { query } from "@9thprotocol/sdk";

for await (const event of query({
  prompt: "fix the failing test in src/auth",
  model: "auto",
  cwd: process.cwd(),
})) {
  if (event.type === "text_delta") process.stdout.write(event.text);
  if (event.type === "tool_start") console.log("→", event.summary);
}
```

```ts theme={null}
type ModelChoice = "auto" | (string & {});

interface QueryOptions {
  prompt: string;
  model?: ModelChoice;
  cwd?: string;
}
```

## Event types

The engine already emits these; the SDK will surface them unchanged:

| Event               | Meaning                                                  |
| ------------------- | -------------------------------------------------------- |
| `model_selected`    | Auto routing picked a model for this message             |
| `text_delta`        | Streaming assistant text                                 |
| `tool_start`        | A tool is about to run                                   |
| `tool_end`          | Result, duration, and whether it errored                 |
| `permission_denied` | A gated action was refused                               |
| `turn_end`          | Token totals for the turn                                |
| `error`             | Failure, with a machine-readable `code` where applicable |

## Licensing

| Package            | License                     |
| ------------------ | --------------------------- |
| `@9thprotocol/sdk` | MIT                         |
| `@9thprotocol/cli` | proprietary                 |
| `agent-core`       | proprietary (not published) |

The SDK is the supported integration surface. The engine itself stays closed.

## Today

Until the SDK lands, drive the CLI as a subprocess:

```bash theme={null}
echo "summarise the failing tests" | 9p --plain
```

Piped input runs each line as a message and exits cleanly, so it composes with
normal shell tooling. Authenticate with `NINEP_API_URL` + `NINEP_TOKEN` in
automation — see [Authentication](/authentication) and
[CLI reference](/cli).
