> ## Documentation Index
> Fetch the complete documentation index at: https://docs.blaxel.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Code reranking/semantic search

> Uses Relace's code reranking model to find the most relevant files for a given query. This is useful as a first pass in agentic exploration to narrow down the search space.

Based on: https://docs.relace.ai/docs/code-reranker/agent

Query Construction: The query can be a short question or a more detailed conversation with the user request included. For a first pass, use the full conversation; for subsequent calls, use more targeted questions.

Token Limit and Score Threshold: For 200k token context models like Claude 4 Sonnet, recommended defaults are scoreThreshold=0.5 and tokenLimit=30000.

The response will be a list of file paths and contents ordered from most relevant to least relevant.



## OpenAPI

````yaml https://raw.githubusercontent.com/blaxel-ai/sandbox/refs/heads/main/sandbox-api/docs/openapi.yml get /codegen/reranking/{path}
openapi: 3.0.0
info:
  contact: {}
  description: API for manipulating filesystem, processes and network.
  title: Sandbox API
  version: 0.0.1
servers:
  - url: https://sbx-{sandbox_id}-{workspace_id}.{region}.bl.run
    variables:
      sandbox_id:
        default: unknown
      workspace_id:
        default: unknown
      region:
        default: unknown
security:
  - BearerAuth: []
paths:
  /codegen/reranking/{path}:
    get:
      tags:
        - codegen
      summary: Code reranking/semantic search
      description: >-
        Uses Relace's code reranking model to find the most relevant files for a
        given query. This is useful as a first pass in agentic exploration to
        narrow down the search space.


        Based on: https://docs.relace.ai/docs/code-reranker/agent


        Query Construction: The query can be a short question or a more detailed
        conversation with the user request included. For a first pass, use the
        full conversation; for subsequent calls, use more targeted questions.


        Token Limit and Score Threshold: For 200k token context models like
        Claude 4 Sonnet, recommended defaults are scoreThreshold=0.5 and
        tokenLimit=30000.


        The response will be a list of file paths and contents ordered from most
        relevant to least relevant.
      parameters:
        - description: Path to search in (relative to workspace)
          in: path
          name: path
          required: true
          schema:
            type: string
        - description: Natural language query to search for
          in: query
          name: query
          required: true
          schema:
            type: string
        - description: 'Minimum relevance score (default: 0.5)'
          in: query
          name: scoreThreshold
          schema:
            type: number
        - description: 'Maximum tokens to return (default: 30000)'
          in: query
          name: tokenLimit
          schema:
            type: integer
        - description: Regex pattern to filter files (e.g., .*\\.ts$ for TypeScript files)
          in: query
          name: filePattern
          schema:
            type: string
      responses:
        '200':
          description: Relevant files found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RerankingResponse'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: Unprocessable entity - failed to process the request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '503':
          description: Service unavailable - Relace not configured
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    RerankingResponse:
      properties:
        files:
          items:
            $ref: '#/components/schemas/RankedFile'
          type: array
        message:
          example: Found 5 relevant files
          type: string
        success:
          example: true
          type: boolean
      type: object
    ErrorResponse:
      properties:
        error:
          example: Error message
          type: string
      required:
        - error
      type: object
    RankedFile:
      properties:
        content:
          type: string
        path:
          type: string
        score:
          type: number
      type: object
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````