POST
/
v2
/
code
/
rank
curl --request POST \
  --url https://ranker.endpoint.relace.run/v2/code/rank \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "query": "Optimize the search function for better performance with large arrays",
  "codebase": [
    {
      "filename": "src/search.ts",
      "code": "function findItem(array: Item[], targetId: string): Item | undefined {\\n  for (let i = 0; i < array.length; i++) {\\n    const item = array[i];\\n    if (item.id === targetId) {\\n      return item;\\n}\\n}\\n  return undefined;\\n}"
    }
  ],
  "token_limit": 100000
}'
{
  "results": [
    {
      "filename": "src/search.ts",
      "score": 0.953125
    }
  ],
  "usage": {
    "total_tokens": 96
  }
}

Authorizations

Authorization
string
header
required

API key Authorization header using the Bearer scheme. Rate limiting applies for certain API keys.

Body

application/json

Query and codebase context for relevance scoring

The body is of type object.

Response

200
application/json

Codebase reranked successfully

The response is of type object.