> ## 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 text, image, video, audio, and PDF inputs

Omit the `Authorization` header for anonymous access.

Per-tier quotas are on [Rate Limits](https://docs.vlm.run/gateway/rate-limits.md). This route shares those quotas with chat completions.

Model ids are on [Models](https://docs.vlm.run/gateway/models.md).

## Request parameters

| Field | Type | Default | Description |
| - | - | - | - |
| `model` | `string` | required | Embedding model id, e.g. `qwen/qwen3-vl-embedding-2b` or `google/embeddinggemma-2`. |
| `input` | `string`, array of strings, array of token ids, or array of content parts | required | Text, or `text` / `image_url` / `video_url` / `audio_url` / `input_audio` / `document_url` / `file` content parts. A list of lists is a batch. See below. |
| `encoding_format` | `string` | `float` | `float` or `base64`. |
| `dimensions` | `integer` | model default | Truncate the output vector to fewer dimensions, if the model supports it. |
| `prompt_name` | `string` | model default | Task prefix for text, on models trained with one. See [Task prefixes and dimensions](#task-prefixes-and-dimensions). |
| `document_pages` | array | all | Pages of a `document_url` part to read: indices, or `[start, stop]` ranges. |
| `document_max_pages` | `integer` | model cap | Pages one document may add to an input. |
| `truncate_prompt_tokens` | `integer` | `null` | Truncate long inputs to this many tokens instead of erroring. |
| `user` | `string` | `null` | Opaque end-user identifier, accepted for OpenAI SDK compatibility. |

Each model lists the extra fields it reads in `supported_parameters` on [`GET /openai/models`](https://docs.vlm.run/gateway/api-reference/get-models).

## Text input

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

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

response = client.embeddings.create(
    model="qwen/qwen3-vl-embedding-2b",
    input="Extract a vector representation for this text.",
)

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

```typescript Node.js theme={"theme":{"light":"github-light","dark":"dark-plus"}}
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://gateway.vlm.run/openai",
  apiKey: process.env.VLMRUN_API_KEY,
});

const response = await client.embeddings.create({
  model: "qwen/qwen3-vl-embedding-2b",
  input: "Extract a vector representation for this text.",
});

console.log(response.data[0].embedding.length);
```

```bash CLI theme={"theme":{"light":"github-light","dark":"dark-plus"}}
vlmrun gw embed -t "Extract a vector representation for this text." \
  -m qwen/qwen3-vl-embedding-2b
```

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

```jsonc 200 theme={"theme":{"light":"github-light","dark":"dark-plus"}}
{
  "id": "embd-00306e5928f441b6a8df9c4c40eea55",
  "object": "list",
  "created": 1792567663,
  "model": "qwen/qwen3-vl-embedding-2b:text",
  "served_model_id": "qwen/qwen3-vl-embedding-2b",
  "backend": "vllm",
  "data": [
    {
      "object": "embedding",
      "index": 0,
      "embedding": [0.009509848430752754, -0.03051667846739292, 0.023419776931405067, /* ... 2048 values in total */]
    }
  ],
  "usage": {
    "prompt_tokens": 9,
    "total_tokens": 9,
    "cost": 0.0
  }
}
```

```json 422 theme={"theme":{"light":"github-light","dark":"dark-plus"}}
{
  "detail": [
    {
      "type": "missing",
      "loc": ["body", "input"],
      "msg": "Field required",
      "input": {
        "model": "qwen/qwen3-vl-embedding-2b"
      }
    }
  ]
}
```

## Multimodal input

`qwen/qwen3-vl-embedding-2b` accepts `image_url` content parts in `input`. A `video_url` part on this model is a `400`.

`google/embeddinggemma-2` accepts `image_url` and `video_url` parts. `video_url` embeds sampled frames.

Image and video vectors share the text vector space.

`google/embeddinggemma-2` also accepts `audio_url`, `input_audio`, and `document_url` parts. A PDF's pages pool into one vector. All parts in one input share one 8,192-token window.

Check `capabilities.supported_input_types` on [`GET /openai/models`](https://docs.vlm.run/gateway/api-reference/get-models) before using a modality.

Not every embedding model accepts images or video.

```python Python [expandable] theme={"theme":{"light":"github-light","dark":"dark-plus"}}
from openai import OpenAI

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

response = client.embeddings.create(
    model="qwen/qwen3-vl-embedding-2b",
    input=[
        {
            "type": "image_url",
            "image_url": {
                "url": "https://storage.googleapis.com/vlm-data-public-prod/hub/examples/image.caption/car.jpg"
            },
        }
    ],
)

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

```typescript Node.js [expandable] theme={"theme":{"light":"github-light","dark":"dark-plus"}}
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://gateway.vlm.run/openai",
  apiKey: process.env.VLMRUN_API_KEY,
});

const response = await client.embeddings.create({
  model: "qwen/qwen3-vl-embedding-2b",
  input: [
    {
      type: "image_url",
      image_url: {
        url: "https://storage.googleapis.com/vlm-data-public-prod/hub/examples/image.caption/car.jpg",
      },
    },
  ],
});

console.log(response.data[0].embedding.length);
```

```bash CLI theme={"theme":{"light":"github-light","dark":"dark-plus"}}
vlmrun gw embed car.jpg -m qwen/qwen3-vl-embedding-2b
```

```bash cURL theme={"theme":{"light":"github-light","dark":"dark-plus"}}
curl https://gateway.vlm.run/openai/embeddings \
  -X POST \
  -H "Authorization: Bearer $VLMRUN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen/qwen3-vl-embedding-2b",
    "input": [
      {
        "type": "image_url",
        "image_url": {
          "url": "https://storage.googleapis.com/vlm-data-public-prod/hub/examples/image.caption/car.jpg"
        }
      }
    ]
  }'
```

## Task prefixes and dimensions

`google/embeddinggemma-2` is trained with a short prefix on text inputs. Set it with `prompt_name`. The default is `Classification`. A wrong prefix still returns a vector, at lower precision. An unknown name is a `400`.

| `prompt_name` | Task | Pair with |
| - | - | - |
| `SearchQuery` | Web and document search | `Document` |
| `QuestionAnswering` | Question answering | `Document` |
| `FactChecking` | Fact checking | `Document` |
| `CodeRetrieval` | Code search | `Document` |
| `Classification` | Text classification | itself |
| `Clustering` | Clustering | itself |
| `SentenceSimilarity` | Semantic similarity | itself |

`dimensions` takes `768`, `512`, `256`, or `128`. The shorter vector is re-normalized. Queries and documents must share one value.

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

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

response = client.embeddings.create(
    model="google/embeddinggemma-2",
    input="What causes the northern lights?",
    dimensions=256,
    extra_body={"prompt_name": "SearchQuery"},
)

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

```bash cURL theme={"theme":{"light":"github-light","dark":"dark-plus"}}
curl https://gateway.vlm.run/openai/embeddings \
  -X POST \
  -H "Authorization: Bearer $VLMRUN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "google/embeddinggemma-2",
    "input": "What causes the northern lights?",
    "dimensions": 256,
    "prompt_name": "SearchQuery"
  }'
```

```jsonc 200 theme={"theme":{"light":"github-light","dark":"dark-plus"}}
{
  "id": "embd-1b49b8e0922e4777a995b4a52ef2ffa",
  "object": "list",
  "created": 1792567672,
  "model": "google/embeddinggemma-2:text",
  "served_model_id": "google/embeddinggemma-2",
  "backend": "sentence-transformers",
  "data": [
    {
      "object": "embedding",
      "index": 0,
      "embedding": [0.017074648290872574, -0.00399424834176898, 0.05659026652574539, /* ... 256 values in total */]
    }
  ],
  "usage": {
    "prompt_tokens": 13,
    "total_tokens": 13,
    "cost": 0.0
  }
}
```

## Billing

A `200` debits your organization by `usage.cost`. The cost is `usage.prompt_tokens` multiplied by the model's prompt price per 1M tokens, rounded to six decimals. Embeddings have no per-call minimum, so a short text input can show `"cost": 0.0`, as in the examples above.

On `google/embeddinggemma-2`, media counts as prompt tokens at fixed rates:

| Input | Prompt tokens |
| - | - |
| Image, or one PDF page | 280 |
| Video frame | 140 |
| Audio second | 25 |

For example, 1,000 images cost 280,000 tokens, which is \$0.0028 at \$0.01 per 1M tokens. Prices per model are on [Models](https://vlm.run/gateway/models).

A free-plan organization with a negative balance, or an organization with an overdue payment, gets a [`402`](https://docs.vlm.run/gateway/error-codes#credits-exhausted-402), as on chat completions. Calls without an API key count toward the same daily anonymous spend cap as chat.

## Related

> [card] [Models](https://vlm.run/gateway/models)
>
> Available embedding models.

> [card] [Supported Inputs](https://docs.vlm.run/gateway/multimodal-inputs.md)
>
> Content part types shared across chat and embeddings.


## OpenAPI

````yaml https://gateway.vlm.run/openapi.json POST /openai/embeddings
openapi: 3.1.0
info:
  title: VLM Run Gateway API
  summary: Unified gateway for computer-vision workloads.
  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.

    [Documentation](https://docs.vlm.run) |
    [Terms of service](https://vlm.run/terms-of-service) |
    [Privacy policy](https://vlm.run/privacy) |
    [VLM Run](https://vlm.run) |
    [Send email to support@vlm.run](mailto:support@vlm.run)
  termsOfService: https://vlm.run/terms-of-service
  contact:
    name: VLM Run
    url: https://vlm.run/gateway
    email: support@vlm.run
  version: 0.59.1
servers:
  - url: https://gateway.vlm.run
    description: Production
  - url: http://localhost:8001
    description: Local development
security: []
paths:
  /openai/embeddings:
    post:
      summary: Embeddings
      description: >-
        OpenAI-compatible ``/v1/embeddings``; routes on ``body.model`` and
        forwards the batch to ``embed``.
      operationId: embeddings_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:
        - _PermissiveHTTPBearer: []
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:
                $ref: '#/components/schemas/EmbeddingContentPart'
              type: array
            - items:
                items:
                  $ref: '#/components/schemas/EmbeddingContentPart'
                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
        prompt_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Prompt Name
        video_fps:
          anyOf:
            - type: number
              exclusiveMinimum: 0
            - type: 'null'
          title: Video Fps
        video_max_frames:
          anyOf:
            - type: integer
              exclusiveMinimum: 0
            - type: 'null'
          title: Video Max Frames
        document_pages:
          anyOf:
            - items: {}
              type: array
            - type: 'null'
          title: Document Pages
        document_max_pages:
          anyOf:
            - type: integer
            - type: 'null'
          title: Document Max Pages
        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 audit extras
        (``served_model_id`` and ``backend``).
    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
            - audio_url
            - input_audio
            - document_url
            - file
          title: Type
        text:
          anyOf:
            - type: string
            - type: 'null'
          title: Text
        image_url:
          anyOf:
            - $ref: '#/components/schemas/vlmrt__chat__types__ImageUrl'
            - type: 'null'
        video_url:
          anyOf:
            - $ref: '#/components/schemas/VideoUrl'
            - type: 'null'
        audio_url:
          anyOf:
            - $ref: '#/components/schemas/AudioUrl'
            - type: 'null'
        input_audio:
          anyOf:
            - $ref: '#/components/schemas/InputAudio'
            - type: 'null'
        document_url:
          anyOf:
            - $ref: '#/components/schemas/vlmrt__chat__types__DocumentUrl'
            - type: 'null'
        file:
          anyOf:
            - $ref: '#/components/schemas/vlmrt__chat__types__FileContent'
            - type: 'null'
      type: object
      required:
        - type
      title: EmbeddingContentPart
      description: >-
        A single content part in a multimodal embedding input.


        Scoped to the parts that make sense for embeddings (no ``role`` and no

        assistant turns): text, an image, a video, a clip of audio, or a PDF
        whose

        pages are rasterised and read as images. ``type`` is the discriminant.
    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
    vlmrt__chat__types__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
    AudioUrl:
      properties:
        url:
          type: string
          title: Url
      type: object
      required:
        - url
      title: AudioUrl
      description: Audio referenced by URL or base64 data URI; resampled to 16 kHz mono.
    InputAudio:
      properties:
        data:
          type: string
          title: Data
        format:
          anyOf:
            - type: string
            - type: 'null'
          title: Format
      type: object
      required:
        - data
      title: InputAudio
      description: 'OpenAI''s ``input_audio``: the clip inline, base64, with its container.'
    vlmrt__chat__types__DocumentUrl:
      properties:
        url:
          type: string
          title: Url
      type: object
      required:
        - url
      title: DocumentUrl
      description: PDF document referenced by URL or base64 data URI.
    vlmrt__chat__types__FileContent:
      properties:
        filename:
          anyOf:
            - type: string
            - type: 'null'
          title: Filename
        file_data:
          type: string
          title: File Data
      type: object
      required:
        - file_data
      title: FileContent
      description: >-
        OpenAI-compatible file attachment (Pydantic AI ``DocumentUrl`` maps
        here).
  securitySchemes:
    _PermissiveHTTPBearer:
      type: http
      scheme: bearer

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.