Skip to main content
POST
/
v1
/
repo
/
{repo_id}
/
retrieve
curl -X POST https://api.relace.run/v1/repo/123e4567-e89b-12d3-a456-426614174000/retrieve \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "authentication and user login functionality",
    "branch": "main",
    "score_threshold": 0.3,
    "token_limit": 30000,
    "include_content": true
  }'
{
  "results": [
    {
      "filename": "src/auth.py",
      "content": "def authenticate_user(username, password):\n    \"\"\"Authenticate user credentials against the database.\"\"\"\n    user = User.query.filter_by(username=username).first()\n    if user and bcrypt.check_password_hash(user.password_hash, password):\n        return user\n    return None",
      "score": 0.94
    },
    {
      "filename": "src/models/user.py",
      "content": "class User(db.Model):\n    id = db.Column(db.Integer, primary_key=True)\n    username = db.Column(db.String(80), unique=True, nullable=False)\n    password_hash = db.Column(db.String(128), nullable=False)",
      "score": 0.87
    }
  ],
  "hash": "a3f82c1d4e9b6f028571d3a2c8e4b96f7d2e5a18",
  "pending_embeddings": 0
}
Repos is now in Public Beta! Reach out to us at info@relace.ai if you have any questions or need help with the integration.

Path Parameters

repo_id
string
required
UUID of the target repo to retrieve over.
Target repo must be created with auto_index: true for semantic retrieval to work.

Request Body

query
string
required
Natural language description of what you’re looking for
branch
string
Branch name to retrieve from. Returns results from the most recently indexed commit on the branch. Uses the default branch if neither branch nor hash is specified.
Updated indices may not be available immediately after an edit/push. If you require results to reflect a recent change, use the hash parameter with the branch HEAD.
hash
string
Specific commit hash to retrieve from. Returns 404 if the commit has not been indexed. In cases where you are retrieving over a recently pushed commit, retry on 404 errors with an exponential backoff.
Only “leaf” commits are indexed. Passing a commit that has never been a branch HEAD will permanently return 404.
score_threshold
number
default:0.3
Minimum relevance score for results (0.0 to 1.0)
token_limit
integer
default:30000
Maximum number of tokens to return across all results
include_content
boolean
default:false
Whether to include file content in the response. If false, only filenames and scores are returned.

Response

results
array
Array of relevant files and code sections
hash
string
Commit hash that was retrieved over
pending_embeddings
integer
Number of embeddings currently in progress
Query time may be slower and results may be degraded when there is a large number of pending embeddings.
curl -X POST https://api.relace.run/v1/repo/123e4567-e89b-12d3-a456-426614174000/retrieve \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "authentication and user login functionality",
    "branch": "main",
    "score_threshold": 0.3,
    "token_limit": 30000,
    "include_content": true
  }'
{
  "results": [
    {
      "filename": "src/auth.py",
      "content": "def authenticate_user(username, password):\n    \"\"\"Authenticate user credentials against the database.\"\"\"\n    user = User.query.filter_by(username=username).first()\n    if user and bcrypt.check_password_hash(user.password_hash, password):\n        return user\n    return None",
      "score": 0.94
    },
    {
      "filename": "src/models/user.py",
      "content": "class User(db.Model):\n    id = db.Column(db.Integer, primary_key=True)\n    username = db.Column(db.String(80), unique=True, nullable=False)\n    password_hash = db.Column(db.String(128), nullable=False)",
      "score": 0.87
    }
  ],
  "hash": "a3f82c1d4e9b6f028571d3a2c8e4b96f7d2e5a18",
  "pending_embeddings": 0
}