feat(models): add hardcoded GPT-Image-2 model support in Codex

- Added `GPT-Image-2` as a built-in model to avoid dependency on remote updates for Codex.
- Updated model tier functions (`CodexFree`, `CodexTeam`, etc.) to include built-in models via `WithCodexBuiltins`.
- Introduced new handlers for image generation and edit operations under `OpenAIAPIHandler`.
- Extended tests to validate 503 response for unsupported image model requests.
This commit is contained in:
Luis Pater
2026-04-22 20:51:13 +08:00
parent 4fc2c619fb
commit e935196df4
6 changed files with 1006 additions and 5 deletions
@@ -1,7 +1,9 @@
package handlers
import (
"net/http"
"reflect"
"strings"
"testing"
"time"
@@ -116,3 +118,22 @@ func TestGetRequestDetails_PreservesSuffix(t *testing.T) {
})
}
}
func TestGetRequestDetails_ImageModelReturns503(t *testing.T) {
handler := NewBaseAPIHandlers(&sdkconfig.SDKConfig{}, coreauth.NewManager(nil, nil, nil))
_, _, errMsg := handler.getRequestDetails("gpt-image-2")
if errMsg == nil {
t.Fatalf("expected error for gpt-image-2, got nil")
}
if errMsg.StatusCode != http.StatusServiceUnavailable {
t.Fatalf("unexpected status code: got %d want %d", errMsg.StatusCode, http.StatusServiceUnavailable)
}
if errMsg.Error == nil {
t.Fatalf("expected error message, got nil")
}
msg := errMsg.Error.Error()
if !strings.Contains(msg, "/v1/images/generations") || !strings.Contains(msg, "/v1/images/edits") {
t.Fatalf("unexpected error message: %q", msg)
}
}