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

# Embeddings

> OpenAI-compatible embeddings for text and image inputs

Authentication is optional. See [Rate Limits](/gateway/rate-limits) for per-tier
quotas. For available embedding models, see [Models](/gateway/models).

<RequestExample>
  ```python Python theme={"theme":{"light":"github-light","dark":"dark-plus"}}
  from openai import OpenAI

  client = OpenAI(
      base_url="https://gateway.vlm.run/v1/openai",
      api_key="<VLMRUN_API_KEY>",
  )

  response = client.embeddings.create(
      model="<embedding-model-id>",
      input="Extract a vector representation for this text.",
  )

  print(len(response.data[0].embedding))
  ```

  ```bash cURL theme={"theme":{"light":"github-light","dark":"dark-plus"}}
  curl https://gateway.vlm.run/v1/openai/embeddings \
    -X POST \
    -H "Authorization: Bearer $VLMRUN_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "<embedding-model-id>",
      "input": "Extract a vector representation for this text."
    }'
  ```
</RequestExample>


## OpenAPI

````yaml gateway/openapi.json POST /v1/openai/embeddings
openapi: 3.1.0
info:
  title: VLM Run Gateway API
  summary: Unified gateway for real-time vision-language inference.
  description: |
    The **VLM Run Gateway API** is the public entry point to the VLM Run
    inference platform. It fronts vision-language and computer-vision models
    behind a single OpenAI-compatible surface plus first-class real-time
    transports.

    [Terms of service](https://vlm.run/terms) |
    [VLM Run](https://vlm.run) |
    [Send email to support@vlm.run](mailto:support@vlm.run)
  termsOfService: https://vlm.run/terms
  contact:
    name: VLM Run
    url: https://vlm.run/
    email: support@vlm.run
  version: 0.10.0
servers:
  - url: https://gateway.vlm.run
    description: Production
  - url: http://localhost:8001
    description: Local development
security: []
paths:
  /v1/openai/embeddings:
    post:
      summary: Embeddings
      description: |-
        OpenAI-compatible ``/v1/embeddings``.

        Routes to the embedding model selected by ``body.model``,
        decodes any ``image_url`` content parts into base64 PNGs, and
        forwards the batch to the deployment's :meth:`embed` RPC.
      operationId: embeddings_v1_openai_embeddings_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EmbeddingRequest'
            example: {}
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EmbeddingResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    EmbeddingRequest:
      properties:
        model:
          type: string
          title: Model
        input:
          anyOf:
            - type: string
            - items:
                type: string
              type: array
            - items:
                type: integer
              type: array
            - items:
                items:
                  type: integer
                type: array
              type: array
            - items:
                anyOf:
                  - type: string
                  - items:
                      $ref: '#/components/schemas/EmbeddingContentPart'
                    type: array
              type: array
          title: Input
        encoding_format:
          type: string
          enum:
            - float
            - base64
          title: Encoding Format
          default: float
        dimensions:
          anyOf:
            - type: integer
            - type: 'null'
          title: Dimensions
        user:
          anyOf:
            - type: string
            - type: 'null'
          title: User
        truncate_prompt_tokens:
          anyOf:
            - type: integer
            - type: 'null'
          title: Truncate Prompt Tokens
      type: object
      required:
        - model
        - input
      title: EmbeddingRequest
      description: |-
        OpenAI-compatible embeddings request.

        The ``input`` field is intentionally polymorphic to match both
        OpenAI's API (string / list-of-strings / list-of-token-ids) and
        vLLM's multimodal extension (list of content parts). The router
        normalises everything to a list of items before handing it to the
        backend, so individual backends only see one shape.
    EmbeddingResponse:
      properties:
        id:
          type: string
          title: Id
        object:
          type: string
          const: list
          title: Object
          default: list
        created:
          type: integer
          title: Created
        model:
          type: string
          title: Model
        served_model_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Served Model Id
        backend:
          anyOf:
            - type: string
            - type: 'null'
          title: Backend
        data:
          items:
            $ref: '#/components/schemas/EmbeddingData'
          type: array
          title: Data
        usage:
          $ref: '#/components/schemas/EmbeddingUsage'
          default:
            prompt_tokens: 0
            total_tokens: 0
      type: object
      required:
        - model
        - data
      title: EmbeddingResponse
      description: OpenAI-compatible embeddings response with vlmrt audit extras.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    EmbeddingContentPart:
      properties:
        type:
          type: string
          enum:
            - text
            - image_url
            - video_url
          title: Type
        text:
          anyOf:
            - type: string
            - type: 'null'
          title: Text
        image_url:
          anyOf:
            - $ref: '#/components/schemas/ImageUrl'
            - type: 'null'
        video_url:
          anyOf:
            - $ref: '#/components/schemas/VideoUrl'
            - type: 'null'
      type: object
      required:
        - type
      title: EmbeddingContentPart
      description: |-
        A single content part in a multimodal embedding input.

        Mirrors :class:`vlmrt.chat.types.ContentPart` but scoped to the
        subset that makes sense for embeddings (no ``role`` / assistant
        turns). ``type`` is the discriminant; exactly one of ``text``,
        ``image_url``, or ``video_url`` is populated.
    EmbeddingData:
      properties:
        object:
          type: string
          const: embedding
          title: Object
          default: embedding
        index:
          type: integer
          title: Index
        embedding:
          anyOf:
            - items:
                type: number
              type: array
            - type: string
          title: Embedding
      type: object
      required:
        - index
        - embedding
      title: EmbeddingData
      description: Single ``data`` entry in an embeddings response.
    EmbeddingUsage:
      properties:
        prompt_tokens:
          type: integer
          title: Prompt Tokens
          default: 0
        total_tokens:
          type: integer
          title: Total Tokens
          default: 0
        cost:
          anyOf:
            - type: number
            - type: 'null'
          title: Cost
      type: object
      title: EmbeddingUsage
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    ImageUrl:
      properties:
        url:
          type: string
          title: Url
        detail:
          type: string
          enum:
            - auto
            - low
            - high
          title: Detail
          default: auto
      type: object
      required:
        - url
      title: ImageUrl
    VideoUrl:
      properties:
        url:
          type: string
          title: Url
      type: object
      required:
        - url
      title: VideoUrl
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````