すべてのプロダクト
Search
ドキュメントセンター

OpenSearch:カスタム デプロイメント サービスの呼び出し

最終更新日:Aug 06, 2025

このトピックでは、API を介してカスタム デプロイメント サービスを呼び出す方法について説明します。

概要

URI

[サービス デプロイメント] > [管理] に移動して、アクセス ドメイン名(インターネットまたはプライベート ネットワーク ドメイン名)を取得します。

image

ヘッダー

  • Content-Type: application/json

  • Authorization: Bearer ${workspace API key}

  • Token: ${サービス デプロイメント Token}。上記の図に示すように、[サービス デプロイメント] > [呼び出し情報] から取得できます。

マルチモーダル埋め込みモデル

リクエスト パラメーター

フィールド名

タイプ

説明

type

String

有効な値:

  • text: テキスト。

  • image: 画像。

image

data

List[String]

各要素は、ベクトル化するテキストまたは画像を表します。 1 回のリクエストに 16 枚を超える画像を含めないことをお勧めします。画像は、data:image/{format};base64,{base64_image} の形式の png および jpeg 形式をサポートしています。

  • 画像タイプ:

    ["data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAoHCB..."]

  • テキストタイプ:

    ["a", "b", "c"]

リクエスト例

curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer Your API Key" \
-H "Token: Replace with service deployment Token" \
"http://xxxxxx.opensearch.aliyuncs.com/v3/openapi/xxxxxx" \
-d '{
  "type": "image",
  "data": ["data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAoHCB..."]
}'
説明

1 つのリクエストでテキストと画像を混在させることはできません。

レスポンス例

{
	"embeddings": [{
			"index": 0,
			"embedding": [0.02272411249577999, -0.0535903535783],
			"type": "image"
		}, {
			"index": 1,
			"embedding": [0.02272411249577999, -0.0535903535783],
			"type": "image"
		}
	]
}

テキスト埋め込み API

リクエスト パラメーター

パラメーター名

タイプ

必須

位置

説明

input

Array/String

はい

body

複数のテキスト入力をサポートし、リクエストごとに最大 16 個までです。 各テキストの長さは、選択したモデルによって異なります。 空の文字列はサポートされていません。

["Science and technology are the primary productive forces","opensearch product documentation"]

input_type

String

いいえ

body

input のデータ型を指定します。有効な値:

  • query

  • document

デフォルト値: document

document

dimension

Int

いいえ

body

出力ディメンション。

説明

このパラメーターは、デプロイされたモデルがベクトル次元削減が有効になっているカスタマイズ モデルの場合にのみ有効になり、値は基礎モデルの次元より大きくすることはできません。

567

リクエスト例

curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer Your API Key" \
-H "Token: Replace with service deployment Token" \
"http://xxxxxx.opensearch.aliyuncs.com/v3/openapi/xxxxxx" \
-d '{
  "input":[
    "Science and technology are the primary productive forces",
    "opensearch product documentation"
  ],
  "input_type" : "document",
  "dimension": 567 # This takes effect only when vector dimensionality reduction training is enabled, and the dimension cannot be greater than that of the foundation model
}'

レスポンス パラメーター

フィールド

タイプ

説明

embeddings

List

リクエストの出力。 このパラメーターは配列です。 配列の各要素は、入力テキストのセグメントに対応します。

[
    {
      "index": 0,
      "embedding": [0.003143,0.009750,omitted,-0.017395]
    },
    {}
]

embeddings[].index

Int

input 内の対応するリクエスト テキストの序数。

0

embeddings[].embedding

List(Double)

ベクトル化結果。

[0.003143,0.009750,omitted,-0.017395]

レスポンス例

{
    "embeddings":[
        {
            "index":0,
            "embedding":[0.003143,0.009750,...,-0.017395]
        },
        {
            "index":1,
            "embedding":[]
        }
    ]
}

リランカー API

リクエスト パラメーター

パラメーター名

タイプ

必須

位置

説明

query

String[]

はい

body

クエリコンテンツ。

docs

List<String>

はい

body

複数のドキュメント コンテンツ。 16 docs を超えない。

リクエスト例

curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer Your API Key" \
-H "Token: Replace with service deployment Token" \
"http://xxxxxx.opensearch.aliyuncs.com/v3/openapi/xxxxxx" \
-d '{
    "query": "opensearch product documentation",
    "docs": [
        "opensearch product documentation",
        "elasticsearch product documentation"
    ]
}'

レスポンス パラメーター

パラメーター名

パラメーター タイプ

説明

scores

List<Double>

docs 内の各 doc のスコア

[0.9860338568687439,0.793461263179779]

レスポンス例

{
    "scores":[
        0.9999276399612427,
        0.8209319710731506
    ]
}

状態コード

詳細については、「AI Search Open Platform 状態コード」をご参照ください。