mirror of
https://gh-proxy.org/https://github.com/klinsmaya/new-api.git
synced 2026-11-09 01:47:07 +08:00
Add the synchronous openai_image host protocol so a task plugin can claim POST /v1/images/generations and /v1/images/edits; the host submits the task, polls it inside the request and lets the plugin render the OpenAI image response. Unclaimed models still fall back to the HTTP image relay. - Migrate Ali (Bailian) image models to the alibaba plugin and remove the ali channel image/wan adaptors and the qwen model setting - Add Doubao Seedream image generation to the doubao plugin - Support retainResult on routes and indexed multipart file references - Settle image counts from upstream usage or image payloads; document the rule in the billing conventions and plugin API docs - Show billing source and task artifacts in usage logs; rename the DoubaoVideo channel display name to Doubao and refresh the favicon
76 lines
1.5 KiB
Go
76 lines
1.5 KiB
Go
package common
|
|
|
|
import "strings"
|
|
|
|
var (
|
|
// OpenAIResponseOnlyModels is a list of models that are only available for OpenAI responses.
|
|
OpenAIResponseOnlyModels = []string{
|
|
"o3-pro",
|
|
"o3-deep-research",
|
|
"o4-mini-deep-research",
|
|
}
|
|
ImageGenerationModels = []string{
|
|
"dall-e-3",
|
|
"dall-e-2",
|
|
"prefix:dall-e", // Deprecated upstream models; retained for compatible routes.
|
|
"gpt-image-",
|
|
"qwen-image",
|
|
"z-image",
|
|
"wan2.7-image-pro",
|
|
"wan2.7-image",
|
|
"wan2.6-image",
|
|
"wan2.6-t2i",
|
|
"wan2.5-t2i-preview",
|
|
"wan2.2-t2i-flash",
|
|
"wan2.2-t2i-plus",
|
|
"wanx2.1-t2i-turbo",
|
|
"wanx2.1-t2i-plus",
|
|
"wanx2.0-t2i-turbo",
|
|
"prefix:imagen-",
|
|
"flux-",
|
|
"flux.1-",
|
|
}
|
|
OpenAITextModels = []string{
|
|
"gpt-",
|
|
"o1",
|
|
"o3",
|
|
"o4",
|
|
"chatgpt",
|
|
}
|
|
)
|
|
|
|
func IsOpenAIResponseOnlyModel(modelName string) bool {
|
|
for _, m := range OpenAIResponseOnlyModels {
|
|
if strings.Contains(modelName, m) {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
func IsImageGenerationModel(modelName string) bool {
|
|
modelName = strings.ToLower(modelName)
|
|
for _, m := range ImageGenerationModels {
|
|
if prefix, ok := strings.CutPrefix(m, "prefix:"); ok {
|
|
if strings.HasPrefix(modelName, prefix) {
|
|
return true
|
|
}
|
|
continue
|
|
}
|
|
if strings.Contains(modelName, m) {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
func IsOpenAITextModel(modelName string) bool {
|
|
modelName = strings.ToLower(modelName)
|
|
for _, m := range OpenAITextModels {
|
|
if strings.Contains(modelName, m) {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|