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

# 建立嵌入

> OpenAI-compatible embeddings for retrieval, clustering, and semantic similarity workloads.



## OpenAPI

````yaml api-reference/openapi.json POST /v1/embeddings
openapi: 3.1.0
info:
  title: DGrid AI Gateway API
  description: >-
    A single, unified API to access 200+ leading AI models. OpenAI-, Claude-,
    and Gemini-compatible endpoints for chat, completions, embeddings, images,
    audio, and moderations.
  version: 1.0.0
  contact:
    name: DGrid AI
    url: https://dgrid.ai
servers:
  - url: https://api.dgrid.ai
    description: DGrid AI Gateway
security:
  - bearerAuth: []
paths:
  /v1/embeddings:
    post:
      tags:
        - Embeddings
      summary: Create embeddings
      description: >-
        OpenAI-compatible embeddings for retrieval, clustering, and semantic
        similarity workloads.
      operationId: createEmbedding
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - input
                - model
              properties:
                input:
                  description: Input text or text array.
                  oneOf:
                    - type: string
                    - type: array
                      items:
                        type: string
                model:
                  type: string
                  description: Embedding model ID.
                encoding_format:
                  type: string
                  enum:
                    - float
                    - base64
                  default: float
                  description: Vector encoding format.
                dimensions:
                  type: integer
                  description: Output vector dimensions.
                user:
                  type: string
                  description: End-user identifier.
            example:
              model: text-embedding-ada-002
              input: The quick brown fox
      responses:
        '200':
          $ref: '#/components/responses/EmbeddingList'
        '400':
          $ref: '#/components/responses/BadRequest'
components:
  responses:
    EmbeddingList:
      description: Embedding results.
      content:
        application/json:
          schema:
            type: object
            properties:
              object:
                type: string
                description: Always `list`.
              data:
                type: array
                description: Embedding results.
                items:
                  type: object
                  properties:
                    object:
                      type: string
                      description: Always `embedding`.
                    embedding:
                      type: array
                      items:
                        type: number
                      description: Embedding vector.
                    index:
                      type: integer
                      description: Embedding index.
              model:
                type: string
                description: Model used for the request.
              usage:
                type: object
                properties:
                  prompt_tokens:
                    type: integer
                  total_tokens:
                    type: integer
    BadRequest:
      description: Invalid request.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            type:
              type: string
            param:
              type: string
            code:
              type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Your DGrid API key. All endpoints use `Authorization: Bearer
        <DGRID_API_KEY>`.

````