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

# 创建向量

> 面向 capabilities.embeddings=true 模型的仅输入计费向量接口。目前没有开通向量模型；开放前需核验模型、维度、整次请求输入上界及输入价格。仅支持 float 向量，批量和可调整维度按模型合同决定。



## OpenAPI

````yaml /openapi.cn.json post /v1/embeddings
openapi: 3.1.0
info:
  title: OmniRelay API
  version: 1.0.0
  description: 面向已核验真实文本模型的兼容 OpenAI 网关。访问按工作空间开通，使用自己的模型列表查询能力与客户价格。
servers:
  - url: https://api.omnirelay.ai
security:
  - bearerAuth: []
tags:
  - name: 服务
  - name: 模型
  - name: 对话
  - name: 管理 API
  - name: 响应
  - name: 向量
  - name: 图片
  - name: 视频
paths:
  /v1/embeddings:
    post:
      tags:
        - 向量
      summary: 创建向量
      description: >-
        面向 capabilities.embeddings=true
        模型的仅输入计费向量接口。目前没有开通向量模型；开放前需核验模型、维度、整次请求输入上界及输入价格。仅支持 float
        向量，批量和可调整维度按模型合同决定。
      operationId: createEmbeddings
      parameters:
        - name: X-Gateway-Tags
          in: header
          required: false
          description: >-
            本次调用的标签，以逗号分隔的 `key=value`，例如 `client=acme,env=prod`。与 API Key
            的默认标签合并；同名 key 以请求体 `tags` 字段为准。`X-OmniRelay-Tags` 是同一个请求头的旧名，继续接受。
          schema:
            type: string
          example: client=acme,env=prod
        - name: X-Gateway-Metadata
          in: header
          required: false
          description: >-
            传 `enabled` 时，响应会附带
            `gateway_metadata`，说明网关为本次调用做出的决定。其他值或不传此头，响应保持不变。`X-OmniRelay-Metadata`
            是同一个请求头的旧名，继续接受。
          schema:
            type: string
            enum:
              - enabled
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EmbeddingsRequest'
      responses:
        '200':
          description: 已验证结果，包含已结算用量和费用。
          headers:
            X-Request-ID:
              description: 用于诊断的 OmniRelay 请求 ID，与模型服务方追踪、响应头及响应体 ID 分别记录。
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EmbeddingsResponse'
        '400':
          description: JSON、标签或参数不合法，模型不支持该能力，或 context_length_exceeded。发往模型服务方前即被拒绝。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: unsupported_parameter
                request_id: 2f6c1d0e9a
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          description: >-
            inference_budget_or_access_denied 表示钱包、Key
            或平台预算无法覆盖预留；member_budget_exceeded 表示成员上限超出。均在派发前拒绝。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: insufficient_balance
                request_id: 2f6c1d0e9a
        '403':
          description: '`model_not_allowed`：该 API Key 仅限调用其他模型。不会扣费。'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: model_not_allowed
                request_id: 2f6c1d0e9a
        '404':
          description: '`model_unavailable`：该模型不存在，或已在此工作区停用。'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: model_unavailable
                request_id: 2f6c1d0e9a
        '413':
          description: payload_too_large：请求体超过 4 MiB（4194304 字节 UTF-8）。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: payload_too_large
                request_id: 2f6c1d0e9a
        '429':
          description: rate_limited：超过账户实际请求频率限制。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: rate_limited
                request_id: 2f6c1d0e9a
        '502':
          description: 模型服务方拒绝、传输失败、响应无效或用量缺失/无效。已发送的调用可能保留预留等待对账；此状态不代表模型服务方未计费。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: >-
            channel_unavailable、live_provider_not_configured、live_provider_unavailable、runtime_maintenance
            或 storage_unavailable。凭据与维护检查在发送前拒绝请求。已发送但结果不明确的请求保留
            pending；不要自动重试付费调用。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: live_provider_not_configured
                request_id: 2f6c1d0e9a
components:
  schemas:
    EmbeddingsRequest:
      type: object
      required:
        - model
        - input
      additionalProperties: false
      properties:
        model:
          type: string
        input:
          oneOf:
            - type: string
              minLength: 1
              maxLength: 65536
            - type: array
              minItems: 1
              maxItems: 65536
              items:
                type: integer
                minimum: 0
                maximum: 2147483647
            - type: array
              minItems: 1
              maxItems: 128
              items:
                type: string
                minLength: 1
                maxLength: 65536
            - type: array
              minItems: 1
              maxItems: 128
              items:
                type: array
                minItems: 1
                maxItems: 65536
                items:
                  type: integer
                  minimum: 0
                  maximum: 2147483647
        encoding_format:
          type: string
          enum:
            - float
          default: float
        dimensions:
          type: integer
          minimum: 1
          maximum: 16384
          description: 要求所选向量模型已验证可调整维度。
        tags:
          type: object
          description: >-
            本次调用的标签。与请求头和 Key 默认标签合并后最多 10 个。key 为 1 至 64 个字符，统一存为小写；value 为 1 至
            128 个字符。两者只能包含字母、数字和 `- _ . : /`。以 `gateway:` 或 `omnirelay:` 开头的 key
            为保留字。`tags` 不是对象时会被忽略。
          additionalProperties:
            type: string
          example:
            client: acme
            project: invoices
    EmbeddingsResponse:
      type: object
      required:
        - object
        - model
        - data
        - usage
        - cost_microusd
      properties:
        object:
          type: string
          enum:
            - list
        model:
          type: string
        data:
          type: array
          items:
            type: object
            required:
              - object
              - index
              - embedding
            properties:
              object:
                type: string
                enum:
                  - embedding
              index:
                type: integer
                minimum: 0
              embedding:
                type: array
                items:
                  type: number
        usage:
          type: object
          properties:
            prompt_tokens:
              type: integer
              minimum: 0
            total_tokens:
              type: integer
              minimum: 0
        cost_microusd:
          type: integer
          description: 按冻结价格、Token 分项、阶梯和折扣计算的已结算费用，单位微美元。整次费用取整后应用折扣，再向上取整。这是最终费用，不是最高预留。
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
            - type
          properties:
            code:
              type: string
              example: model_unavailable
            message:
              type: string
              example: The model does not exist or is disabled.
              description: 用于日志和 SDK 异常的简短英文说明；措辞可能调整，请按 code 判断。
            type:
              type: string
              example: not_found_error
              description: >-
                按 HTTP
                状态划分的错误类别：invalid_request_error、authentication_error、insufficient_quota、permission_error、not_found_error、conflict_error、rate_limit_error、service_unavailable
                或 api_error。
            param:
              type: string
              maxLength: 200
              description: 可识别时返回被拒绝的请求字段路径，不包含参数值；Responses 使用原生字段名。
        request_id:
          type: string
          description: 在对话补全、Responses 和 Embeddings 出错时返回。
  responses:
    Unauthorized:
      description: '`unauthorized`：缺少 API Key，或该 Key 已吊销或无效。'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: unauthorized
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: 在 OmniRelay 控制台创建的 API Key。所有者确认身份后可在控制台再次查看。

````

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