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

# SDK Quickstart

> Import GitAgent as a Node.js library and call query() from your own application or script.

## Install

```bash theme={null}
npm install @open-gitagent/gitagent
```

## Two ways to call query()

There are two ways to call `query()`, depending on whether you already have an OpenGAP agent repo or just want to point the SDK at an existing project.

### Path 1 — With repo URL

```ts theme={null}
import { query } from "@open-gitagent/gitagent";

for await (const msg of query({
  prompt: "Summarise the open pull requests",
  repo: "https://github.com/your-gitagent",
})) {
  if (msg.type === "assistant") console.log(msg.content);
}
```

Clones the repo, reads `agent.yaml`, `SOUL.md`, and skills automatically. Zero local setup.

### Path 2 — Without repo

```ts theme={null}
import { query } from "@open-gitagent/gitagent";

for await (const msg of query({
  prompt: "Refactor the auth module in src/auth.ts",
  model: "anthropic:claude-sonnet-4-6",
  dir: "./my-project",
})) {
  if (msg.type === "assistant") console.log(msg.content);
}
```

No agent directory required. Points at a local working directory — ideal for embedding in an existing codebase or CI pipeline.

<Tip>
  Both paths use the same `query()` function. Pick Path 1 when you already have (or want to clone) an OpenGAP agent repo, and Path 2 when you just want to drop GitAgent into an existing codebase.
</Tip>

## Next steps

<CardGroup cols={2}>
  <Card title="SDK Reference" icon="code" href="/open-source/gitagent/sdk/overview">
    Full API reference for query(), tool(), buildTool(), and hooks
  </Card>

  <Card title="Utilities" icon="wrench" href="/open-source/gitagent/sdk/utilities">
    Context compaction and cost tracking helpers
  </Card>

  <Card title="Telemetry" icon="chart-line" href="/open-source/gitagent/sdk/telemetry">
    Wire up OpenTelemetry spans and metrics
  </Card>

  <Card title="Architecture" icon="folder-tree" href="/open-source/gitagent/architecture">
    Understand the agent directory structure and agent.yaml
  </Card>
</CardGroup>
