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

Make a Template Repo

Create a Relace repo from your base codebase and save the repo_id:
import requests

url = "https://api.relace.run/v1/repo"
headers = {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json"
}

data = {
    "source": {
        "type": "git",
        "url": "https://github.com/username/my-base-template",
        "branch": "main"
    }
}

response = requests.post(url, headers=headers, json=data)
template_repo = response.json()
template_repo_id = template_repo['repo_id']
print(f"Template repository created with ID: {template_repo_id}")

2

Create Repo from Relace Template

Now you can use the saved template_repo_id to quickly create new Relace repos:
import requests

url = "https://api.relace.run/v1/repo"
headers = {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json"
}

data = {
    "source": {
        "type": "relace",
        "repo_id": template_repo_id,
    },
    "metadata": {...}  # Optional: add any custom properties
}

response = requests.post(url, headers=headers, json=data)
new_repo = response.json()
print(f"New repository created with ID: {new_repo['repo_id']}")
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.