POST
/
v1
/
repo
/
{repo_id}
/
retrieve
curl -X POST https://api.relace.ai/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",
    "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
    }
  ]
}

Path Parameters

repo_id
string
required
Repo ID

Request Body

query
string
required
Natural language description of what you’re looking for
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
curl -X POST https://api.relace.ai/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",
    "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
    }
  ]
}