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

# Embed Code

> Embed code snippets into a vector database for semantic search.



## OpenAPI

````yaml POST /v1/code/embed
openapi: 3.0.1
info:
  title: Relace API
  description: API for accessing Relace code generation models.
  version: 1.0.0
  license:
    name: MIT
servers:
  - url: https://instantapply.endpoint.relace.run
    description: Server for code application endpoints
  - url: https://ranker.endpoint.relace.run
    description: Server for code ranking endpoints
  - url: https://embeddings.endpoint.relace.run
    description: Server for code embedding endpoints
  - url: https://api.relace.run
    description: Server for general infrastructure
security:
  - bearerAuth: []
paths:
  /v1/code/embed:
    post:
      description: Embed code snippets into a vector database for semantic search.
      requestBody:
        description: Codebase context for embedding
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/v1CodeEmbedderRequest'
            example:
              model: relace-embed-v1
              input:
                - input 1
                - input 2
      responses:
        '200':
          description: Codebase embedded successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/v1CodeEmbedderResponse'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error400'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error401'
        '404':
          description: API key not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error404'
        '429':
          description: Rate limit exceeded
          headers:
            X-RateLimit-Limit:
              schema:
                type: string
              description: Rate limit ceiling for the API key
            X-RateLimit-Remaining:
              schema:
                type: string
              description: Number of requests left for the time window
            X-RateLimit-Reset:
              schema:
                type: string
              description: Time at which the rate limit resets
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error429'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error500'
      servers:
        - url: https://embeddings.endpoint.relace.run
components:
  schemas:
    v1CodeEmbedderRequest:
      type: object
      properties:
        model:
          type: string
          description: The model to use for embedding
        input:
          type: array
          description: Array of strings to embed
          items:
            type: string
        output_dtype:
          type: string
          description: >-
            Data type of the output embedding vectors. The `binary` quantization
            results in more compact embeddings with only a small loss in
            retrieval performance. See [HuggingFace blog
            post](https://huggingface.co/blog/embedding-quantization#binary-quantization)
            for details.
          enum:
            - float
            - binary
          default: float
    v1CodeEmbedderResponse:
      type: object
      properties:
        results:
          type: array
          description: Array of embeddings of the input strings
          items:
            type: object
            properties:
              index:
                type: integer
                description: Index of the input string in the request
              embedding:
                type: array
                description: Embedding vector of the input string
            example:
              - index: 0
                embedding:
                  - 0.123
                  - 0.456
                  - 0.789
              - index: 1
                embedding:
                  - 0.234
                  - 0.567
                  - 0.89
        usage:
          type: object
          properties:
            total_tokens:
              type: integer
              description: Total number of tokens used
              example: 8
          description: Token usage information for the request
    Error400:
      type: object
      properties:
        error:
          type: string
          description: Error message
          example: Invalid JSON in request body
    Error401:
      type: object
      properties:
        error:
          type: string
          description: Error message
          example: Authorized header required
    Error404:
      type: object
      properties:
        error:
          type: string
          description: Error message
          example: 'Bad Request: Route not found'
    Error429:
      type: object
      properties:
        error:
          type: string
          description: Error message
          example: Rate limit exceeded
    Error500:
      type: object
      properties:
        error:
          type: string
          description: Error message
          example: Error fetching from origin server
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Relace API key Authorization header using the Bearer scheme.

````