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

# Agentic Search

> Learn how to import a GitHub project into Relace Repos for agentic search

## Prerequisites

* [Sign up](https://app.relace.ai) for a Relace account.
* Create an [API key](https://app.relace.ai/settings/api-keys).
* Connect to the Relace [GitHub App](/docs/repos/github-integration).

<Steps>
  <Step title="Import GitHub Project">
    We'll start by creating a new Relace Repo using GitHub as a `source`. We use GitHub as an easy example, but agentic search will work over any Relace Repo.

    ```typescript theme={null}
    import { Relace } from "@relace-ai/relace";

    const client = new Relace({ apiKey: "YOUR_API_KEY" });

    const repo = await client.repo.create({
        source: {
            type: "git",
            url: "https://github.com/relace-ai/vite-template",
            branch: "main"
        }
    });

    const repoId = repo.repo_id;
    console.log(`Repository created with ID: ${repoId}`);
    ```
  </Step>

  <Step title="Perform Agentic Search">
    You can now use the `search` endpoint to find relevant files based on a query in natural language!

    ```typescript theme={null}
    import { Relace } from "@relace-ai/relace";

    const client = new Relace({ apiKey: "YOUR_API_KEY" });

    const results = await client.repo.search(repoId, {
        query: "Add a user profile component with avatar and edit functionality"
    });

    for await (const event of results) {
        console.log(event);
    }
    ```

    The response will be a stream of Server-Sent Events with real-time updates as the agent explores the repo. The final `report_back` event provides an explanation of the findings and the relevant files with line ranges.

    ```json theme={null}
    {
      "name": "report_back",
      "explanation": "The user profile components live in src/components/UserProfile.tsx, with shared types in src/types/user.ts. ...",
      "files": {
        "src/components/UserProfile.tsx": [[1, 120]],
        "src/types/user.ts": [[1, 40]]
      }
    }
    ```

    For more details, see our [API reference](/api-reference/agents/fast-agentic-search).
  </Step>
</Steps>
