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

# Create embeddings

> Request parameters, responses, and channel compatibility.

`POST /v1/embeddings`

Send JSON with an explicit `model` and nonempty text `input`. Use a string array for a batch. This reference covers portable text inputs; upstream token-ID arrays are not guaranteed across channels.

Start with `encoding_format: float`. Confirm channel support for `dimensions`, Base64, and model-specific parameters. Match responses to inputs by `data[].index` and check counts, dimensions, and values before storing. This endpoint returns vectors, not a document index, and the request described here is not SSE.

[Guide and runnable example](/en/guides/embeddings)

[简体中文](/zh/api-reference/embeddings)


## OpenAPI

````yaml openapi/relay.json POST /v1/embeddings
openapi: 3.0.3
info:
  title: API — Core inference API
  version: 0.5.0
  description: >-
    面向接入的精选规范，不是全部管理或供应商接口。 / Curated integration specification, not the entire
    management or provider API.
  license:
    name: AGPL-3.0-or-later
servers:
  - url: https://gateway.example.com
    description: >-
      Example only; replace with your gateway origin and optional path prefix,
      without /v1.
security:
  - BearerAuth: []
paths:
  /v1/embeddings:
    post:
      summary: 生成文本向量 / Create text embeddings
      description: >-
        同步 JSON 接口，模型和渠道决定可选参数支持情况 / Synchronous JSON endpoint; model and
        channel determine optional parameter support
      operationId: createEmbeddings
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EmbeddingRequest'
      responses:
        '200':
          description: >-
            成功结构；仍需校验索引与实际数值，示例向量维度和分数仅作结构演示 / Success shape; validate indices
            and values; example vector dimensions and scores are illustrative
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EmbeddingResult'
              example:
                object: list
                model: YOUR_MODEL_ID
                data:
                  - object: embedding
                    index: 0
                    embedding:
                      - 0.6
                      - 0.8
                usage:
                  prompt_tokens: 2
                  total_tokens: 2
        '400':
          description: 请求参数错误 / Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: 身份校验失败 / Authentication failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: 访问被拒绝 / Access denied
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: 接口或资源不存在 / Endpoint or resource not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: 请求被限流或受配额限制 / Rate or quota restriction
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: 网关或上游错误 / Gateway or upstream error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: 服务暂不可用 / Service unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        default:
          description: 其他网关或上游错误；格式可能不同 / Other gateway or upstream error; shape may vary
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    EmbeddingRequest:
      type: object
      properties:
        model:
          type: string
          description: >-
            支持此接口且当前密钥可用的模型 / Model available to this key and supporting this
            endpoint
          example: YOUR_MODEL_ID
        input:
          description: >-
            可迁移基线：非空文本或非空文本数组；token ID 输入不保证跨渠道兼容 / Portable baseline: nonempty
            text or text array; token-ID inputs are not guaranteed across
            channels
          oneOf:
            - type: string
              minLength: 1
            - type: array
              minItems: 1
              items:
                type: string
                minLength: 1
        encoding_format:
          type: string
          description: >-
            请求向量编码，需渠道支持；推荐显式 float / Requested vector encoding when supported;
            explicitly request float for the baseline
          enum:
            - float
            - base64
        dimensions:
          type: integer
          description: >-
            输出维度，仅部分模型/渠道支持，不能任意截断 / Output dimensions, only for supporting
            models/channels; do not truncate arbitrarily
          minimum: 1
        user:
          type: string
          description: >-
            可选应用用户标识；非认证凭据，转发取决于渠道 / Optional application user identifier, not
            authentication; forwarding depends on channel
      required:
        - model
        - input
    EmbeddingResult:
      type: object
      properties:
        object:
          type: string
          example: list
        model:
          type: string
        data:
          type: array
          items:
            type: object
            properties:
              object:
                type: string
                example: embedding
              index:
                type: integer
                description: >-
                  输入的零基索引，不是数组顺序保证 / Zero-based input index; array ordering is
                  not a guarantee
                minimum: 0
              embedding:
                description: >-
                  float 数组；Base64 字符串仅在实际支持时返回 / Float array; Base64 string only
                  when actually supported
                oneOf:
                  - type: array
                    items:
                      type: number
                  - type: string
            required:
              - index
              - embedding
        usage:
          type: object
          properties:
            prompt_tokens:
              type: integer
            total_tokens:
              type: integer
      required:
        - data
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            type:
              type: string
            param:
              type: string
              nullable: true
            code:
              nullable: true
              description: 错误标识；类型随上游变化 / Error identifier; type varies by upstream
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: 模型调用 API Key，不是控制台登录凭据 / Model API key, not console login credentials

````

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