Skip to content

Commit ae6c5ea

Browse files
committed
feat(runtime): add support for gpt-image-1.5 and direct image API proxying
- Introduced the `gpt-image-2` model in Codex built-ins and updated visibility logic in the registry. - Added direct proxy support for OpenAI image generation and editing endpoints. - Implemented new execution paths for `/images/generations` and `/images/edit`, ensuring seamless handling for both JSON and multipart payloads. - Expanded test coverage to validate the new model and direct proxy features, including streaming scenarios and error handling.
1 parent 41c52b9 commit ae6c5ea

9 files changed

Lines changed: 665 additions & 17 deletions

File tree

config.example.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ disable-claude-cloak-mode: false
132132
# - "passthrough": never inject or strip image_generation on non-images endpoints (forward the client payload unchanged); behaves like "chat" on /v1/images/* endpoints.
133133
disable-image-generation: false
134134

135-
# Base model used when proxying gpt-image-2 via the hosted image_generation tool (Responses API).
135+
# Base model used by the legacy hosted image_generation tool path when a Codex image request is not proxied directly through the Image API.
136136
# Must start with "gpt-" (case-insensitive). If unset or invalid, defaults to "gpt-5.4-mini".
137137
# gpt-image-2-base-model: "gpt-5.4-mini"
138138

internal/config/sdk_config.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ type SDKConfig struct {
2121
// sent it and do not inject it otherwise; on /v1/images/generations and /v1/images/edits behave like "chat".
2222
DisableImageGeneration DisableImageGenerationMode `yaml:"disable-image-generation" json:"disable-image-generation"`
2323

24-
// GPTImage2BaseModel sets the base (mainline) model used when proxying GPT Image 2
25-
// requests via the hosted image_generation tool (e.g. Codex OAuth /v1/images/*).
24+
// GPTImage2BaseModel sets the base (mainline) model used by the legacy hosted
25+
// image_generation tool path when a Codex image request is not proxied directly
26+
// through the Image API.
2627
//
2728
// The value must start with "gpt-" (case-insensitive). If empty or invalid, the
2829
// default base model ("gpt-5.4-mini") is used.

internal/registry/model_definitions.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
)
88

99
const (
10+
codexBuiltinImage15ModelID = "gpt-image-1.5"
1011
codexBuiltinImageModelID = "gpt-image-2"
1112
xaiBuiltinImageModelID = "grok-imagine-image"
1213
xaiBuiltinImageQualityModelID = "grok-imagine-image-quality"
@@ -119,7 +120,7 @@ func GetXAIModels() []*ModelInfo {
119120
// not depend on remote models.json updates. Built-ins replace any matching IDs
120121
// already present in the provided slice.
121122
func WithCodexBuiltins(models []*ModelInfo) []*ModelInfo {
122-
return upsertModelInfos(models, codexBuiltinImageModelInfo())
123+
return upsertModelInfos(models, codexBuiltinImage15ModelInfo(), codexBuiltinImageModelInfo())
123124
}
124125

125126
// WithXAIBuiltins injects hard-coded xAI image/video model definitions that should
@@ -136,6 +137,18 @@ func normalizeAntigravityCapabilityModelID(modelID string) string {
136137
return modelID
137138
}
138139

140+
func codexBuiltinImage15ModelInfo() *ModelInfo {
141+
return &ModelInfo{
142+
ID: codexBuiltinImage15ModelID,
143+
Object: "model",
144+
Created: 1704067200, // 2024-01-01
145+
OwnedBy: "openai",
146+
Type: "openai",
147+
DisplayName: "GPT Image 1.5",
148+
Version: codexBuiltinImage15ModelID,
149+
}
150+
}
151+
139152
func codexBuiltinImageModelInfo() *ModelInfo {
140153
return &ModelInfo{
141154
ID: codexBuiltinImageModelID,

0 commit comments

Comments
 (0)