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

# Direct Embeddings

> Generate embeddings with the OpenAI-compatible direct endpoint.

> [card] [Guide: Embeddings](https://docs.gloo.com/api-guides/embeddings.md)
>
> Model choice, input limits, pricing, and using the OpenAI SDK against this endpoint.

> [card] [Error Reference](https://docs.gloo.com/api-reference/general/errors.md)
>
> Authentication, billing, invalid model or input, unsupported dimensions, and provider errors.


## OpenAPI

````yaml post /ai/v2/direct/embeddings
openapi: 3.1.0
info:
  title: AI API
  description: |-
    Optimized for high-speed inference and scalability by Gloo AI

    [Swagger UI](./docs) | [ReDoc UI](./redoc)
  version: 1.0.0
servers:
  - url: https://platform.ai.gloo.com
security:
  - bearerAuth: []
tags:
  - name: Content Controls
  - name: Data Engine
  - name: Ingestion & Enrichment
  - name: answers
  - name: chat
  - name: completions
  - name: content
  - name: core
  - name: data
  - name: get-models
  - name: ingestion
  - name: sotc
  - name: v1
  - name: v2
  - name: decisions
paths:
  /ai/v2/direct/embeddings:
    post:
      tags:
        - v2
      summary: Direct Embeddings
      description: >-
        Turn one string, or a batch of up to 2048 strings, into embedding
        vectors with a Gloo embedding model. OpenAI-compatible. No guardrails,
        routing, or streaming.
      operationId: post-v2-direct-embeddings
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EmbeddingsRequest'
      responses:
        '200':
          description: Embeddings, one per input string, in input order.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EmbeddingsResponse'
        '400':
          description: >-
            Bad Request - not an embedding model; invalid `input` or
            `encoding_format`; unsupported or out-of-range `dimensions`; a
            rejected dimension alias; or a provider rejection such as input
            exceeding `max_input_tokens`. Not retryable.
          content:
            application/json:
              schema:
                type: object
                required:
                  - detail
                properties:
                  detail:
                    type: object
                    properties:
                      message:
                        type: string
                      type:
                        type: string
                      code:
                        type: string
                      retryable:
                        type: boolean
                      param:
                        type: string
              example:
                detail:
                  message: >-
                    Model 'gloo-openai-gpt-4.1-mini' is not an embedding model.
                    /ai/v2/direct/embeddings serves the embedding models listed
                    by /platform/v2/models.
                  type: invalid_request_error
                  code: invalid_request_error
                  retryable: false
                  param: model
        '401':
          description: Authentication failed or the organization is denylisted.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AiErrorResponse'
        '402':
          description: The organization's prepaid credit balance is exhausted.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AiErrorResponse'
        '403':
          description: The caller is not permitted to use the organization account.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AiErrorResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
        '429':
          description: >-
            Too Many Requests - the organization reached its spending limit
            (`1005 / SPENDING_LIMIT_EXCEEDED`) or monthly API spend limit (`1009
            / MONTHLY_SPEND_LIMIT_REACHED`). Not retryable.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AiErrorResponse'
        '503':
          description: >-
            The embedding provider is unavailable, is temporarily limiting
            requests, or returned empty, incomplete, unusable, or incorrectly
            encoded vectors (`2002 / PROVIDER_UNAVAILABLE`, retryable). Retry
            with bounded exponential backoff. Embeddings requests do not fail
            over to another provider.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AiErrorResponse'
              example:
                detail: The provider is currently unavailable. Please try again later.
                error:
                  message: >-
                    The provider is currently unavailable. Please try again
                    later.
                  type: service_unavailable_error
                  code: 2002
                  name: PROVIDER_UNAVAILABLE
                  category: provider_error
                  description: The upstream model provider is temporarily unavailable.
                  fault: provider
                  retryable: true
                  trace_id: trace-id
components:
  schemas:
    EmbeddingsRequest:
      type: object
      title: EmbeddingsRequest
      required:
        - model
        - input
      additionalProperties: true
      description: >-
        OpenAI-compatible embeddings request. Provider-specific parameters are
        forwarded except reserved fields. `stream` and `provider` are not
        forwarded; `dimension`, `output_dimension`, and `output_dimensionality`
        are rejected. `user` is accepted and ignored.
      properties:
        model:
          type: string
          title: Model
          description: >-
            An embedding model's Gloo Model ID (e.g.
            `gloo-openai-text-embedding-3-small`). Only models whose
            `output_modalities` include `embeddings` on `GET
            /platform/v2/models` are accepted.
          examples:
            - gloo-openai-text-embedding-3-small
        input:
          title: Input
          description: >-
            The text to embed: a non-empty string, or an array of 1 to 2048
            non-empty strings. Each string must fit within the model's
            `max_input_tokens`. Arrays of token IDs are not accepted.
          oneOf:
            - type: string
              minLength: 1
              pattern: \S
            - type: array
              items:
                type: string
                minLength: 1
                pattern: \S
              minItems: 1
              maxItems: 2048
          examples:
            - - In the beginning was the Word.
              - Love is patient.
        encoding_format:
          type: string
          enum:
            - float
            - base64
          title: Encoding Format
          description: >-
            How each vector is encoded. `float` requests an array of numbers;
            `base64` requests little-endian float32 bytes as a base64 string.
            When omitted, the provider's default applies. Providers may not
            support every encoding.
        dimensions:
          type: integer
          exclusiveMinimum: 0
          title: Dimensions
          description: >-
            Requested vector width. Support and accepted values depend on the
            embedding model. Unsupported models or values return 400. The public
            model catalog reports native dimensions but does not publish
            shortened-width constraints.
        user:
          type: string
          title: User
          description: Accepted for OpenAI SDK compatibility and ignored.
    EmbeddingsResponse:
      type: object
      title: EmbeddingsResponse
      required:
        - object
        - data
        - model
      properties:
        object:
          type: string
          const: list
        data:
          type: array
          items:
            $ref: '#/components/schemas/Embedding'
          description: One embedding per input string, in input order.
        model:
          type: string
          description: The `model` value exactly as you sent it.
        usage:
          type: object
          description: >-
            Tokens billed for the request. Omitted if the provider reported no
            usage.
          properties:
            prompt_tokens:
              type: integer
            total_tokens:
              type: integer
      example:
        object: list
        data:
          - object: embedding
            index: 0
            embedding:
              - 0.4155
              - 0.7861
              - -0.2673
              - 0.3721
          - object: embedding
            index: 1
            embedding:
              - -0.0755
              - -0.301
              - -0.6606
              - 0.6841
        model: gloo-openai-text-embedding-3-small
        usage:
          prompt_tokens: 11
          total_tokens: 11
    AiErrorResponse:
      type: object
      title: AiErrorResponse
      description: >-
        AI API error response with existing detail field plus enriched error
        metadata.
      required:
        - detail
        - error
      properties:
        detail:
          description: Existing endpoint-specific error detail. May be a string or object.
        error:
          $ref: '#/components/schemas/AiError'
      additionalProperties: true
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    Embedding:
      type: object
      title: Embedding
      required:
        - object
        - index
        - embedding
      properties:
        object:
          type: string
          const: embedding
        index:
          type: integer
          description: Position of the corresponding string in `input`.
        embedding:
          description: >-
            The vector: an array of floats, or a base64 string when
            `encoding_format` is `base64`.
          oneOf:
            - type: array
              items:
                type: number
            - type: string
    AiError:
      type: object
      title: AiError
      description: >-
        Standard AI API error object emitted by global provider/model error
        handlers.
      required:
        - message
        - type
        - code
        - name
        - category
        - description
        - fault
        - retryable
        - trace_id
      properties:
        message:
          type: string
          description: Request-specific customer-facing error message.
        type:
          type: string
          description: Stable wire-format error type.
        code:
          type: integer
          description: Stable numeric internal error code.
        name:
          type: string
          description: Stable symbolic error code name.
        category:
          type: string
          enum:
            - client_error
            - provider_error
            - platform_error
          description: Error category derived from the numeric code range.
        description:
          type: string
          description: Stable one-sentence explanation of what the error code means.
        fault:
          type: string
          enum:
            - client
            - provider
            - internal
          description: System responsible for the failure.
        retryable:
          type: boolean
          description: Whether retrying the same request may succeed.
        trace_id:
          type:
            - string
            - 'null'
          description: Sentry trace identifier when available.
      additionalProperties: true
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: api-key
      x-default: Bearer <api-key>
      description: >-
        Bearer authentication header of the form Bearer `<api-key>`, where
        `<api-key>` is your [API key](/studio/manage-api-credentials).

````

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