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

# Create Embeddings

> Turn text into embedding vectors.

OpenAI-compatible: point the OpenAI SDK's embeddings client at this gateway and it
works unchanged. `input` takes a single string or a batch, and the response keeps
the input order so you can zip results back to your records.

`model` is required and must name a specific embedding model — `auto` is rejected,
because a vector is only comparable to other vectors from the same model, so
silently choosing one for you would corrupt an index. Provider failover and BYOK
keys apply as they do to chat.



## OpenAPI

````yaml /api/openapi.json post /v1/embeddings
openapi: 3.1.0
info:
  title: MeshAPI
  description: One key, all AI models.
  version: 0.1.0
servers:
  - url: https://api.meshapi.ai
security:
  - BearerAuth: []
paths:
  /v1/embeddings:
    post:
      tags:
        - Embeddings
      summary: Create Embeddings
      description: >-
        Turn text into embedding vectors.


        OpenAI-compatible: point the OpenAI SDK's embeddings client at this
        gateway and it

        works unchanged. `input` takes a single string or a batch, and the
        response keeps

        the input order so you can zip results back to your records.


        `model` is required and must name a specific embedding model — `auto` is
        rejected,

        because a vector is only comparable to other vectors from the same
        model, so

        silently choosing one for you would corrupt an index. Provider failover
        and BYOK

        keys apply as they do to chat.
      operationId: create_embeddings
      parameters:
        - in: header
          name: X-Mesh-Version
          required: false
          schema:
            type: string
            enum:
              - 2026-08
            default: 2026-08
          example: 2026-08
          description: >-
            Dated version of the API contract to pin this request to. Omit it
            and the request is served under `2026-08` — the oldest supported
            version, so an existing integration is never moved by a release. A
            malformed or unsupported value is rejected with `400
            invalid_api_version` rather than falling back silently. The version
            actually served is echoed as `X-Mesh-Version` on every response,
            including errors.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EmbeddingsRequest'
            examples:
              default:
                summary: Example request
                value:
                  model: openai/text-embedding-3-small
                  input: The quick brown fox jumps over the lazy dog.
      responses:
        '200':
          description: Embedding response
          content:
            application/json:
              schema: {}
              examples:
                default:
                  summary: Successful embedding response
                  value:
                    object: list
                    data:
                      - object: embedding
                        index: 0
                        embedding:
                          - -0.03264831379055977
                          - -0.03786936774849892
                          - 0.007462255656719208
                    model: amazon/titan-embed-text-v2
                    usage:
                      prompt_tokens: 3
                      total_tokens: 3
        '400':
          description: Model does not support embeddings API
          content:
            application/json:
              example:
                error:
                  code: model_capability_not_supported
                  message: Model 'gpt-4o' does not support the embeddings API.
                request_id: req_01ARZ3NDEKTSV4RRFFQ69G5FAV
        '401':
          description: Missing or invalid API key
          content:
            application/json:
              example:
                error:
                  code: unauthorized
                  message: Invalid or missing API key.
                request_id: req_01ARZ3NDEKTSV4RRFFQ69G5FAV
        '402':
          description: Insufficient balance or spend cap reached
          content:
            application/json:
              examples:
                spend_cap_reached:
                  summary: Per-key spend cap reached
                  value:
                    error:
                      code: spend_limit_exceeded
                      message: >-
                        Spend cap of $10.0000 reached. Current spend: $10.0023.
                        Contact your administrator to increase the cap.
                    request_id: req_01ARZ3NDEKTSV4RRFFQ69G5FAV
                no_balance:
                  summary: Insufficient credit balance
                  value:
                    error:
                      code: spend_limit_exceeded
                      message: >-
                        Insufficient balance. Top up your account to use paid
                        models.
                    request_id: req_01ARZ3NDEKTSV4RRFFQ69G5FAV
        '403':
          description: API key is suspended
          content:
            application/json:
              example:
                error:
                  code: forbidden
                  message: API key is suspended.
                request_id: req_01ARZ3NDEKTSV4RRFFQ69G5FAV
        '422':
          description: Request validation failed
          content:
            application/json:
              example:
                error:
                  code: validation_error
                  message: Request validation failed.
                  details:
                    - type: missing
                      loc:
                        - body
                        - input
                      msg: Field required
                request_id: req_01ARZ3NDEKTSV4RRFFQ69G5FAV
        '429':
          description: Rate limit exceeded (RPM or RPD)
          content:
            application/json:
              examples:
                rpm_exceeded:
                  summary: Requests-per-minute limit hit
                  value:
                    error:
                      code: rate_limit_exceeded
                      message: RPM limit of 60 req/min exceeded.
                    request_id: req_01ARZ3NDEKTSV4RRFFQ69G5FAV
                rpd_exceeded:
                  summary: Requests-per-day limit hit
                  value:
                    error:
                      code: rate_limit_exceeded
                      message: RPD limit of 1000 req/day exceeded.
                    request_id: req_01ARZ3NDEKTSV4RRFFQ69G5FAV
        '500':
          description: Upstream provider error or gateway timeout
          content:
            application/json:
              examples:
                upstream_error:
                  summary: Upstream provider returned an error
                  value:
                    error:
                      code: upstream_error
                      message: Upstream provider returned an error.
                      upstream_detail: >-
                        {"error":{"message":"Input too large for
                        model","code":413}}
                    request_id: req_01ARZ3NDEKTSV4RRFFQ69G5FAV
                gateway_timeout:
                  summary: Upstream timed out
                  value:
                    error:
                      code: gateway_timeout
                      message: Upstream provider did not respond in time.
                    request_id: req_01ARZ3NDEKTSV4RRFFQ69G5FAV
                internal_error:
                  summary: >-
                    Internal platform error (DB failure — FastAPI default
                    format)
                  value:
                    detail: Internal Server Error
        '503':
          description: Upstream provider temporarily unavailable
          content:
            application/json:
              example:
                error:
                  code: provider_not_available
                  message: >-
                    The model provider is temporarily unavailable. Please try
                    again shortly.
                request_id: req_01ARZ3NDEKTSV4RRFFQ69G5FAV
      security:
        - BearerAuth: []
components:
  schemas:
    EmbeddingsRequest:
      properties:
        model:
          anyOf:
            - type: string
            - type: 'null'
          title: Model
          description: Model ID to use for embedding, e.g. `perplexity/pplx-embed-v1-4b`.
          examples:
            - perplexity/pplx-embed-v1-4b
            - openai/text-embedding-3-small
        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/MultimodalEmbeddingInput'
              type: array
          title: Input
          description: >-
            Text(s) to embed. Accepts a string, list of strings, list of token
            IDs, list of token ID lists, or a list of MultimodalEmbeddingInput
            objects (for BytePlus multimodal embedding models).
        dimensions:
          anyOf:
            - type: integer
              minimum: 1
            - type: 'null'
          title: Dimensions
          description: >-
            Number of dimensions for the output embedding vector
            (model-dependent).
        encoding_format:
          anyOf:
            - type: string
              enum:
                - float
                - base64
            - type: 'null'
          title: Encoding Format
          description: Format of the returned embedding. Defaults to `float`.
        input_type:
          anyOf:
            - type: string
            - type: 'null'
          title: Input Type
          description: >-
            Intended use of the embedding, e.g. `query` or `document`. Some
            models use this to apply asymmetric embedding.
        provider:
          anyOf:
            - type: string
            - $ref: '#/components/schemas/ProviderPreferences'
            - type: 'null'
          title: Provider
          description: >-
            Provider routing preferences. Pass a provider slug string (e.g.
            `'perplexity'`) or a `ProviderPreferences` object to control
            fallback and ordering behaviour.
        user:
          anyOf:
            - type: string
              maxLength: 256
            - type: 'null'
          title: User
          description: End-user identifier for abuse monitoring.
        instructions:
          anyOf:
            - type: string
            - type: 'null'
          title: Instructions
          description: >-
            Inference prompt for BytePlus multimodal embeddings. A default is
            generated from the input modality if not set.
        sparse_embedding:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Sparse Embedding
          description: >-
            Sparse vector switch for BytePlus text embeddings. Pass {"type":
            "enabled"} to return both dense and sparse vectors, or {"type":
            "disabled"} for dense only.
      type: object
      required:
        - input
      title: EmbeddingsRequest
      description: |-
        Request body for `POST /v1/embeddings`.

        Mirrors the OpenAI embeddings API. The `input` field accepts
        four shapes:

        - **string** — a single text to embed
        - **list[string]** — a batch of texts
        - **list[int]** — a single pre-tokenised input (token IDs)
        - **list[list[int]]** — a batch of pre-tokenised inputs
      example:
        input: Hello world
        model: amazon/titan-embed-text-v2
    MultimodalEmbeddingInput:
      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/ImageEmbeddingUrl'
            - type: 'null'
        video_url:
          anyOf:
            - $ref: '#/components/schemas/VideoEmbeddingUrl'
            - type: 'null'
      type: object
      required:
        - type
      title: MultimodalEmbeddingInput
      description: >-
        A single item in a BytePlus multimodal embeddings input list.


        BytePlus /embeddings/multimodal accepts a list of typed content objects

        instead of plain strings. All items in one request are vectorized
        together

        as a single unit (e.g. one image + one text → one combined vector).
    ProviderPreferences:
      properties:
        order:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Order
          description: Preferred provider order, e.g. ['perplexity', 'openai'].
        allow_fallbacks:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Allow Fallbacks
          description: Whether to fall back to other providers if the first is unavailable.
        require_parameters:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Require Parameters
          description: Only use providers that support all requested parameters.
        data_collection:
          anyOf:
            - type: string
              enum:
                - allow
                - deny
            - type: 'null'
          title: Data Collection
          description: Control whether the provider may use the request for training.
      type: object
      title: ProviderPreferences
      description: Provider routing preferences.
    ImageEmbeddingUrl:
      properties:
        url:
          type: string
          title: Url
      type: object
      required:
        - url
      title: ImageEmbeddingUrl
    VideoEmbeddingUrl:
      properties:
        url:
          type: string
          title: Url
      type: object
      required:
        - url
      title: VideoEmbeddingUrl
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        Enter your MeshAPI key (`rsk_...`) — sent as `Authorization: Bearer
        <key>`.

````