获取可用模型
返回指定类型的可用模型。用它查找可配置到知识库的
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
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。