利用可能なモデルを取得
指定したタイプの利用可能なモデルを返します。ナレッジベースに設定する
text-embedding モデルと rerank モデルを見つけるために使用します。1 min read
get/workspaces/current/models/model-types/{model_type}
Request example
curl --request GET \
--url https://api.dify.ai/v1/workspaces/current/models/model-types/{model_type} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.dify.ai/v1/workspaces/current/models/model-types/{model_type}"
headers = {
"Authorization": "Bearer <token>",
}
response = requests.request("GET", url, headers=headers)
print(response.text)const response = await fetch('https://api.dify.ai/v1/workspaces/current/models/model-types/{model_type}', {
method: 'GET',
headers: {
'Authorization': 'Bearer <token>'
}
});
const data = await response.json();
console.log(data);<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'https://api.dify.ai/v1/workspaces/current/models/model-types/{model_type}',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer <token>',
],
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;package main
import (
"fmt"
"io"
"net/http"
)
func main() {
url := "https://api.dify.ai/v1/workspaces/current/models/model-types/{model_type}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.dify.ai/v1/workspaces/current/models/model-types/{model_type}"))
.header("Authorization", "Bearer <token>")
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());require 'uri'
require 'net/http'
url = URI('https://api.dify.ai/v1/workspaces/current/models/model-types/{model_type}')
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = url.scheme == 'https'
request = Net::HTTP::Get.new(url)
request['Authorization'] = 'Bearer <token>'
response = http.request(request)
puts response.read_bodyResponse
{
"data": [
{
"icon_small": {
"en_US": "https://example.com/openai-small.svg",
"zh_Hans": "https://example.com/openai-small.svg"
},
"icon_small_dark": null,
"label": {
"en_US": "OpenAI",
"zh_Hans": "OpenAI"
},
"models": [
{
"deprecated": false,
"features": null,
"fetch_from": "predefined-model",
"has_invalid_load_balancing_configs": false,
"label": {
"en_US": "text-embedding-3-small",
"zh_Hans": "text-embedding-3-small"
},
"load_balancing_enabled": false,
"model": "text-embedding-3-small",
"model_properties": {
"context_size": 8191
},
"model_type": "text-embedding",
"status": "active"
}
],
"provider": "langgenius/openai/openai",
"status": "active",
"tenant_id": "11223344-5566-7788-99aa-bbccddeeff00"
}
]
}get/workspaces/current/models/model-types/{model_type}
Authorization
すべてのリクエストは API キーで認証します:Authorization: Bearer {API_KEY}。アプリのエンドポイントにはアプリの API キーを、ナレッジのエンドポイントにはナレッジベースの API キーを使用します(Dify API クイックスタート)。
キーはサーバーサイドで保管し、クライアントコードには決して埋め込まないでください。キーが欠落または無効なリクエストは HTTP 401(unauthorized)で失敗します。
Path parameters
取得するモデルのタイプです。ナレッジベースの設定には、埋め込みモデルの場合は
text-embedding、リランキングモデルの場合は rerank を使用します。Options:
text-embeddingrerankllmttsspeech2textmoderationResponses
application/json
200
指定された種類で利用可能なモデルです。
利用可能なモデルを持つモデルプロバイダーのリストです。
Show child attributesHide child attributes
プロバイダーの小アイコンの URL です。
ダークモード用アイコンの URL。プロバイダーにない場合は
null。プロバイダーのローカライズ表示名です。
このプロバイダーから利用可能なモデルのリストです。
Show child attributesHide child attributes
モデルが非推奨かどうか。
モデルがサポートする機能です。なしの場合は
null です。モデル定義の取得元です。
predefined-model は組み込みモデル、customizable-model はユーザー設定モデルを示します。モデルに無効なロードバランシング設定があるかどうか。
モデルのローカライズ表示名です。
モデルのロードバランシングが有効かどうか。
モデル識別子です。ナレッジベースの作成または更新時に
embedding_model の値として使用します。context_size などのモデル固有のプロパティです。モデルのタイプです。
model_type パスパラメータと一致します。モデルの利用可能ステータスです。使用可能な場合は
active です。モデルプロバイダーの識別子です。
organization/plugin_name/provider_name の形式です(例:langgenius/openai/openai)。以前のプロバイダーでは短縮形(例:openai)が返される場合があります。プロバイダーのステータスです。認証情報が設定済みで有効な場合は
active です。このプロバイダー設定が属するワークスペース ID。