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

# 创建 Embeddings

> 使用 Jina embeddings 从文本生成 embedding 向量，通过 OpenAI 兼容的 AIsa 中继提供服务。

为一个或多个输入字符串生成 embedding 向量。传入非空的 `input` 字符串，或传入字符串数组做批量 embedding。请求和响应均为 OpenAI 兼容，因此只要把 `base_url` 指向 AIsa 中继，OpenAI SDK 无需修改即可使用。

**可用模型**（输出均为 1024 维）：

* `jina-embeddings-v3`
* `jina-embeddings-v5-text-small`

通过 AIsa 中继路径 `/v1/embeddings` 提供服务——OpenAI 兼容。按 token 计费，**每 100 万 tokens \$0.050**；`usage.total_tokens` 字段给出每次请求计费的 token 数。

<CodeGroup>
  ```bash curl theme={null}
  curl https://api.aisa.one/v1/embeddings \
    -H "Authorization: Bearer $AISA_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "jina-embeddings-v3",
      "input": "A fast, OpenAI-compatible embeddings endpoint."
    }'
  ```

  ```bash curl (v5-text-small) theme={null}
  curl https://api.aisa.one/v1/embeddings \
    -H "Authorization: Bearer $AISA_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "jina-embeddings-v5-text-small",
      "input": "A fast, OpenAI-compatible embeddings endpoint."
    }'
  ```

  ```python Python theme={null}
  from openai import OpenAI

  client = OpenAI(base_url="https://api.aisa.one/v1", api_key="sk-aisa-...")

  resp = client.embeddings.create(
      model="jina-embeddings-v5-text-small",  # or "jina-embeddings-v3"
      input="A fast, OpenAI-compatible embeddings endpoint.",
  )

  print(resp.data[0].embedding)  # 1024-dim vector
  ```
</CodeGroup>


## OpenAPI

````yaml openapi/zh/jina.json POST /embeddings
openapi: 3.0.3
info:
  title: Jina Embeddings & Rerank API
  version: 1.0.0
  description: >-
    通过 AIsa 中继（OpenAI 兼容）路径提供的 Jina embedding 和重排序服务。包含文本
    embedding（jina-embeddings-v3 和 jina-embeddings-v5-text-small，输出均为 1024
    维）以及文档重排序（jina-reranker-v3）。两个 endpoint 均按 token 计费，每 100 万 tokens $0.050。
servers:
  - url: https://api.aisa.one/v1
security:
  - BearerAuth: []
tags:
  - name: Embeddings & Rerank
paths:
  /embeddings:
    post:
      summary: 创建 embeddings
      description: >-
        使用 jina-embeddings-v3 或 jina-embeddings-v5-text-small（输出均为 1024
        维）为一个或多个输入字符串生成 embedding 向量。请求和响应均为 OpenAI 兼容。通过 AIsa 中继路径
        /v1/embeddings 提供服务。按 token 计费，每 100 万 tokens $0.050。
      operationId: createEmbedding
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - model
                - input
              properties:
                model:
                  type: string
                  description: >-
                    Embedding 模型名称。可选：jina-embeddings-v3 或
                    jina-embeddings-v5-text-small（输出均为 1024 维）。
                  enum:
                    - jina-embeddings-v3
                    - jina-embeddings-v5-text-small
                  example: jina-embeddings-v3
                input:
                  description: 要做 embedding 的非空字符串，或非空字符串数组。
                  oneOf:
                    - type: string
                    - type: array
                      items:
                        type: string
                      minItems: 1
                  example: A fast, OpenAI-compatible embeddings endpoint.
            example:
              model: jina-embeddings-v3
              input: A fast, OpenAI-compatible embeddings endpoint.
      responses:
        '200':
          description: Embedding 列表。
          content:
            application/json:
              schema:
                type: object
                properties:
                  object:
                    type: string
                    example: list
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        object:
                          type: string
                          example: embedding
                        index:
                          type: integer
                          example: 0
                        embedding:
                          type: array
                          description: 1024 维 embedding 向量。
                          items:
                            type: number
                            format: float
                  model:
                    type: string
                    example: jina-embeddings-v3
                  usage:
                    type: object
                    properties:
                      total_tokens:
                        type: integer
                        example: 9
              example:
                object: list
                data:
                  - object: embedding
                    index: 0
                    embedding:
                      - 0.0123
                      - -0.0456
                      - 0.0789
                model: jina-embeddings-v3
                usage:
                  total_tokens: 9
components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key

````