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

# 创建文本嵌入

> 将文本转换为向量嵌入



## OpenAPI

````yaml /api.json post /v1/embeddings
openapi: 3.0.1
info:
  title: TKHub API
  description: TKHub 平台 API 接口文档
  version: 1.0.0
servers:
  - url: https://api.tkhub.ai
    description: 生产环境
  - url: https://api-test.tkhub.ai
    description: 测试环境
security:
  - bearerAuth: []
paths:
  /v1/embeddings:
    post:
      tags:
        - OpenAI格式(Embeddings)
      summary: 创建文本嵌入
      description: 将文本转换为向量嵌入
      operationId: createEmbedding
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EmbeddingRequest'
        required: true
      responses:
        '200':
          description: 成功创建嵌入
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EmbeddingResponse'
          headers: {}
      deprecated: false
      security:
        - BearerAuth: []
components:
  schemas:
    EmbeddingRequest:
      type: object
      required:
        - model
        - input
      properties:
        model:
          type: string
          example: text-embedding-ada-002
        input:
          oneOf:
            - type: string
            - type: array
              items:
                type: string
          description: 要嵌入的文本
        encoding_format:
          type: string
          enum:
            - float
            - base64
          default: float
        dimensions:
          type: integer
          description: 输出向量维度
    EmbeddingResponse:
      type: object
      properties:
        object:
          type: string
          example: list
        data:
          type: array
          items:
            type: object
            properties:
              object:
                type: string
                example: embedding
              index:
                type: integer
              embedding:
                type: array
                items:
                  type: number
        model:
          type: string
        usage:
          type: object
          properties:
            prompt_tokens:
              type: integer
            total_tokens:
              type: integer
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: |
        使用 Bearer Token 认证。
        格式: `Authorization: Bearer sk-xxxxxx`

````