mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-09-21 14:19:18 +08:00
@@ -49,6 +49,9 @@ func (s *OpenAIGatewayService) forwardGrokResponses(
|
||||
if strings.TrimSpace(upstreamModel) == "" {
|
||||
upstreamModel = grokDefaultResponsesModel
|
||||
}
|
||||
if isGrokImageGenerationModel(upstreamModel) {
|
||||
return nil, fmt.Errorf("model %s is an image model and is not available on the Responses endpoint; use /v1/images/generations instead", upstreamModel)
|
||||
}
|
||||
cacheIdentity := resolveGrokCacheIdentity(c, body, "", upstreamModel)
|
||||
patchedBody, err := patchGrokResponsesBody(body, upstreamModel)
|
||||
if err != nil {
|
||||
|
||||
@@ -2037,3 +2037,25 @@ func TestPatchGrokResponsesBody_MultipleReasoningContentNull(t *testing.T) {
|
||||
require.False(t, items[0].Get("content").Exists())
|
||||
require.False(t, items[2].Get("content").Exists())
|
||||
}
|
||||
|
||||
func TestIsGrokImageGenerationModel(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
model string
|
||||
want bool
|
||||
}{
|
||||
{"grok-imagine", true},
|
||||
{"grok-imagine-image-quality", true},
|
||||
{"grok-imagine-edit", true},
|
||||
{"grok-imagine-image-hd", true},
|
||||
{"grok-4.5", false},
|
||||
{"grok-composer", false},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.model, func(t *testing.T) {
|
||||
require.Equal(t, tt.want, isGrokImageGenerationModel(tt.model))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user