> ## 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.

# Semantic Search

> Learn how to import a GitHub project into Relace Repos for semantic 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](/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 semantic 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"
        },
        auto_index: true // Required for semantic search
    });

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

    Behind the scenes, we clone your repo and kick of an asychronous job to intelligently chunk and index the codebase with our [code embeddings](/embeddings/quickstart) model.

    This process is usually fast, but for very large repositories (*i.e.* 100+ MB), it can take upwards of 5 minutes.
  </Step>

  <Step title="Perform Semantic Search">
    You can now use the `retrieve` endpoint to score files based on relevance to a query in natural language!

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

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

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

    const results = response.results;
    ```

    The response will be a list of objects that provide a relevance score for each file.

    ```json theme={null}
    [
      {
        "filename": "src/components/UserProfile.tsx",
        "score": 0.9598
      },
      {
        "filename": "src/types/user.ts",
        "score": 0.0321
      },
      {
        "filename": "src/components/Header.tsx",
        "score": 0.0014
      }
    ]
    ```

    For more details, see our [API reference](/api-reference/repos/retrieve).
  </Step>
</Steps>
