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

# Embeddings

> Turn text into vectors for semantic search, RAG, clustering, and deduplication.

Send text as `input` and get back OpenAI's embeddings envelope: an `object` of `list`, a `data` array with one `{ object, index, embedding }` entry per input, the resolved `model`, and `usage`. It is drop-in compatible with OpenAI's Embeddings API, so an existing client only needs its base URL and model id changed. See the [Embeddings](/docs/embeddings) guide for a prefilled example, or a model page ([all-minilm-l6-v2](/api-reference/models/all-minilm-l6-v2), [bge-small-en-v1.5](/api-reference/models/bge-small-en-v1-5)) for an interactive playground.

Embedding models are routable **only** on this endpoint. A `/responses` or `/chat/completions` call with an embedding model returns `400`. Pass `input` as a string, or as an array of strings to embed a batch in one request; `data[i].index` maps each vector back to its input. Both models return 384-dimensional vectors, so they are interchangeable in an existing index.

Embeddings are billed on input tokens only. `usage` carries `prompt_tokens` and `total_tokens`, and there are no output tokens to bill.

Install the official SDK from [npm](https://www.npmjs.com/package/zerogpu-api) or [PyPI](https://pypi.org/project/zerogpu-api/) (`pip install zerogpu-api`). Source: [zerogpu/SDK](https://github.com/zerogpu/SDK). Handle errors the same way as [API error codes](/docs/production-patterns#handle-status-codes-explicitly).


## OpenAPI

````yaml api-reference/openapi/zerogpu.openapi.json POST /embeddings
openapi: 3.1.0
info:
  title: ZeroGPU API
  version: '1.0'
  description: >-
    REST API for ZeroGPU model inference: `POST /v1/responses` and `POST
    /v1/chat/completions` (model-dependent).

    Authentication uses the `x-api-key` header on every request. The
    `x-project-id` header is optional.

    Documentation: https://docs.zerogpu.ai


    **Per-model playgrounds** are listed on [Model
    playgrounds](/api-reference/models) with request examples for each model's
    use cases.

    These endpoint pages show a generic shape only.
servers:
  - url: https://api.zerogpu.ai/v1
    description: Production
security:
  - ApiKey: []
paths:
  /embeddings:
    post:
      tags:
        - Embeddings
      summary: Create embedding
      operationId: createEmbedding
      parameters:
        - name: x-project-id
          in: header
          required: false
          schema:
            type: string
          description: >-
            Optional project identifier. Scopes the request to a specific
            project when provided.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateEmbeddingRequest'
            example:
              model: all-minilm-l6-v2
              input: >-
                ZeroGPU runs high-volume inference tasks on small models at the
                edge.
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EmbeddingResponse'
              example:
                object: list
                data:
                  - object: embedding
                    index: 0
                    embedding:
                      - 0.012601
                      - -0.072932
                      - 0.043332
                      - 0.028129
                      - 0.033064
                      - -0.078302
                      - -0.153619
                      - -0.011621
                model: all-MiniLM-L6-v2
                usage:
                  prompt_tokens: 18
                  total_tokens: 18
        '400':
          description: Bad request (invalid body)
        '401':
          description: Unauthorized (invalid or missing API key)
        '403':
          description: Forbidden (invalid project ID or permissions)
        '420':
          description: Insufficient quota (insufficient_quota)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal server error
components:
  schemas:
    CreateEmbeddingRequest:
      type: object
      required:
        - model
        - input
      properties:
        model:
          type: string
          description: >-
            Embedding model to use. Embedding models are routable only on this
            endpoint.
          enum:
            - all-minilm-l6-v2
            - bge-small-en-v1.5
          example: all-minilm-l6-v2
        input:
          description: >-
            Text to embed. A single string, or an array of strings (one vector
            per element). Inputs are truncated at the model's max token length.
          oneOf:
            - type: string
              minLength: 1
            - type: array
              minItems: 1
              items:
                type: string
                minLength: 1
    EmbeddingResponse:
      type: object
      description: An OpenAI-compatible embedding list.
      properties:
        object:
          type: string
          example: list
        data:
          type: array
          items:
            $ref: '#/components/schemas/Embedding'
        model:
          type: string
          description: The resolved model id.
          example: all-MiniLM-L6-v2
        usage:
          $ref: '#/components/schemas/EmbeddingUsage'
    ErrorResponse:
      type: object
      description: Error payload returned on a failed request.
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              description: Machine-readable error code, for example `insufficient_quota`.
              example: insufficient_quota
            message:
              type: string
              description: Human-readable description of the error.
              example: You have insufficient quota to complete this request.
    Embedding:
      type: object
      properties:
        object:
          type: string
          example: embedding
        index:
          type: integer
          description: Position of the input this vector was produced from.
          example: 0
        embedding:
          type: array
          description: The embedding vector. 384 dimensions for both models.
          items:
            type: number
    EmbeddingUsage:
      type: object
      description: Embeddings are billed on input tokens only; there are no output tokens.
      properties:
        prompt_tokens:
          type: integer
          example: 18
        total_tokens:
          type: integer
          example: 18
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        Your ZeroGPU API key. Create one in the dashboard under API keys. Send
        it on every request.

````