OpenRouter answers a chat request for gpt-image-*, seedream, flux, qwen-image, grok-imagine and the like with 404 "Use the /api/v1/images endpoint instead", and viaFor sent every OpenRouter model to chat. Models catalog.ImagesAPI names now go to OpenRouter's POST /images, with reference images as input_references (image_url parts) and its media_type and prompt/completion token usage read back; a 404 there is returned as is rather than retried on chat. Gemini and gpt-5-image stay on chat. The provider Test probe asks the same endpoint. Run: go test -tags nogui ./internal/gateway/ ./internal/provider/ ./internal/catalog/, go vet (darwin, linux nogui, windows), gofmt. With the /images dispatch removed, both new gateway tests go red. The real case (owner's OpenRouter key, sandbox HOME, a throwaway test not committed): openai/gpt-image-1-mini at quality low drew one image, 200, usage 12/272, and with that image as a reference drew again, 200, usage 1035/272. The request shape matches OpenRouter's openapi.json ImageGenerationRequest.
35 lines
1.1 KiB
Go
35 lines
1.1 KiB
Go
package provider
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
)
|
|
|
|
func TestOpenRouterImageModelProbeUsesImagesAPI(t *testing.T) {
|
|
p := Provider{Chat: "https://openrouter.ai/api/v1"}
|
|
if !p.drawsOnImages("openai/gpt-image-2") {
|
|
t.Fatal("OpenRouter gpt-image model is not probed on its images API")
|
|
}
|
|
if p.drawsOnImages("openai/gpt-5-image") {
|
|
t.Fatal("OpenRouter chat image model should stay on chat completions")
|
|
}
|
|
url, body := tinyDrawing(p, "openai/gpt-image-2")
|
|
if url != "https://openrouter.ai/api/v1/images" {
|
|
t.Fatalf("image probe URL %q", url)
|
|
}
|
|
var got map[string]any
|
|
if err := json.Unmarshal([]byte(body), &got); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if got["model"] != "openai/gpt-image-2" || got["prompt"] != "a dot" || got["n"] != float64(1) || got["quality"] != "low" {
|
|
t.Fatalf("image probe body %s", body)
|
|
}
|
|
other := Provider{Chat: "https://relay.example/v1"}
|
|
if !other.drawsOnImages("gpt-image-2") {
|
|
t.Fatal("OpenAI-compatible image model is not probed on its images API")
|
|
}
|
|
if url, _ := tinyDrawing(other, "gpt-image-2"); url != "https://relay.example/v1/images/generations" {
|
|
t.Fatalf("other provider image probe URL %q", url)
|
|
}
|
|
}
|