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

# Relace Templates

> Create a template as a starting point for new Relace repos

If you have a base repo as a starting point for your agent, it's recommended to turn it into a template Relace repo.

<Steps>
  <Step title="Make a Template Repo">
    Create a Relace repo from your base codebase and save the `repo_id`:

    <CodeGroup>
      ```typescript From GitHub theme={null}
      import { Relace } from "@relace-ai/relace";

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

      const templateRepo = 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 templateRepoId = templateRepo.repo_id;
      console.log(`Template repository created with ID: ${templateRepoId}`);
      ```

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

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

      const templateRepo = await client.repo.create({
          source: {
              type: "files",
              files: [
                  {
                      filename: "src/agent.py",
                      content: "class Agent:\n    def __init__(self):\n        self.name = 'BaseAgent'\n    \n    def process(self, input_data):\n        # Base processing logic\n        return input_data"
                  },
                  // Add more template files as needed
              ]
          },
          auto_index: true // Required for semantic search
      });

      const templateRepoId = templateRepo.repo_id;
      console.log(`Template repository created with ID: ${templateRepoId}`);
      ```
    </CodeGroup>
  </Step>

  <Step title="Create Repo from Relace Template">
    Now you can use the saved `template_repo_id` to quickly create new Relace repos:

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

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

    const newRepo = await client.repo.create({
        source: {
            type: "relace",
            repo_id: templateRepoId,
        },
        auto_index: true, // Required for semantic search
        metadata: {} // Optional: add any custom properties
    });

    console.log(`New repository created with ID: ${newRepo.repo_id}`);
    ```
  </Step>
</Steps>

Repo creation with a Relace template is nearly instantaneous, as you no longer pay the latency cost of transferring these base files over the network.
