POST
/
v1
/
code
/
rank
curl --request POST \
  --url https://ranker.endpoint.relace.run/v1/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}"
    },
    {
      "filename": "src/types.ts",
      "code": "interface Item {\n  id: string;\n  value: string;\n  metadata?: Record<string, unknown>;\n}"
    },
    {
      "filename": "src/render.ts",
      "code": "function renderItems(items: Item[]): void {\\n  const container = document.getElementById('\''items-container'\'');\\n  if (!container) return;\\n  \\n  container.innerHTML = '\'''\'';\\n  \\n  for (const item of items) {\\n    const element = document.createElement('\''div'\'');\\n    element.textContent = item.value;\\n    element.dataset.id = item.id;\\n    container.appendChild(element);\\n}\\n}"
    },
    {
      "filename": "src/styles.css",
      "code": ".container {\\n  max-width: 1200px;\\n  margin: 0 auto;\\n  padding: 20px;\\n}\\n\\n.header {\\n  background: #f5f5f5;\\n  padding: 1rem;\\n}"
    },
    {
      "filename": "src/constants.ts",
      "code": "export const APP_NAME = '\''MyApp'\'';\\nexport const VERSION = '\''1.0.0'\'';\\nexport const MAX_ITEMS = 1000;"
    }
  ],
  "token_limit": 100000
}'
[
  "src/search.ts",
  "src/styles.css",
  "src/render.ts",
  "src/constants.ts",
  "src/types.ts"
]

Authorizations

Authorization
string
header
required

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

Body

application/json

Query, codebase context, and token limit

The body is of type object.

Response

200
application/json

Codebase reranked successfully

Array of files ranked by relevance to the query