Skip to content

Add Requesty as an image generation provider - #17

Open
Thibaultjaigu wants to merge 2 commits into
geekjourneyx:mainfrom
thibault-forks:add-requesty-provider
Open

Thibaultjaigu wants to merge 2 commits into
geekjourneyx:mainfrom
thibault-forks:add-requesty-provider

Conversation

@Thibaultjaigu

@Thibaultjaigu Thibaultjaigu commented Jul 1, 2026 •

Copy link
Copy Markdown

This adds Requesty as an image provider through the existing provider registry, available as requesty or rq.

Requesty (https://router.requesty.ai/v1) is an OpenAI compatible router that serves image models via /chat/completions. The response carries the generated image as a base64 data URL in choices[0].message.images[0].image_url.url, which is what this provider parses. HTTPS image URLs are not part of the contract and are rejected with parse_error. Contract reference: https://docs.requesty.ai/features/image-generation

Changes:

  • internal/image/requesty.go: new RequestyProvider. The request sends model, messages and image_config with aspect_ratio and image_size, no modalities. IMAGE_SIZE accepts an aspect ratio (16:9), a 1K / 2K / 4K tier, or an exact WIDTHxHEIGHT from the Requesty dimension table; anything else is a ConfigError instead of a silent substitution. Default is 1:1 at 1K, matching what Requesty applies when image_config is omitted. Errors keep the router message and code and distinguish unauthorized, forbidden, payment_required, rate_limit, model_not_found, bad_request. A trailing slash on a custom base URL is trimmed.
  • internal/image/provider.go: requesty registry entry with the ids the router serves today: vertex/gemini-3.1-flash-image (default), vertex/gemini-3-pro-image, vertex/gemini-2.5-flash-image.
  • internal/config/config.go: defaults for base URL, model and size.
  • Tests: request body contract, the full 10x3 dimension table, unsupported size rejection, malformed JSON and data URLs, every error class, requesty / rq factory and registry lookup, config defaults for both names, providers show rq --json.
  • Docs: docs/IMAGE_PROVISIONERS.md (models, size table, error table), docs/CONFIG.md, docs/FAQ.md, docs/DISCOVERY.md, docs/AGENT-GUIDE.md, README.md, CHANGELOG.md.

Verified locally on the rebased branch: gofmt -l ., go vet ./..., golangci-lint 2.5.0 (0 issues), CGO_ENABLED=1 go test -count=1 ./..., npm pack --dry-run, make release-check. Smoke test against the live router with vertex/gemini-3.1-flash-image, image_config: {aspect_ratio: "16:9", image_size: "1K"} and no modalities returned a 1376x768 PNG data URL.

Disclosure: I work at Requesty. Happy to adjust anything to match project conventions.

Copy link
Copy Markdown
Owner

Thanks for the contribution — adding Requesty through the provider registry is a reasonable fit, and the response/data-URL path broadly matches the existing OpenRouter integration. I don't think this is merge-ready yet, though.

Recommendation: request changes / do not merge yet.

Blocking

  1. Please rebase and resolve conflicts against current main. GitHub currently reports mergeable_state: dirty / rebaseable: false. The branch is based on 56c714e, while provider defaults, discovery tests, docs, and release metadata have moved since then; conflict resolution must preserve those newer changes.

  2. The registered model IDs do not match Requesty's current documented image-generation contract. The PR uses:

    • default: google/gemini-3.1-flash-image-preview
    • alternate: vertex/gemini-2.5-flash-image

    Requesty's current Image Generation documentation lists vertex/gemini-3.1-flash-image-preview and vertex/google/gemini-2.5-flash-image-preview for the chat-completions path. Because the default is duplicated across the registry, config defaults, docs, and tests, a stale ID makes the out-of-box provider path invalid. Please verify the IDs against the live Requesty model catalog, then update all four layers together. The official request example also omits modalities; please either align the payload or add an API fixture/smoke result demonstrating that modalities: ["image"] is accepted.

  3. Requesty must not reuse mapSizeToOpenRouter unchanged. Requesty's documented dimensions differ from OpenRouter's table. For example, Requesty documents 1376x768 for 16:9 at 1K, but this implementation only recognizes 1344x768; 1376x768 silently falls back to 1:1 / 2K. Likewise, GetRequestySupportedImageSizes() advertises 1K, 2K, and 4K, but passing 1K through the current mapper also becomes 1:1 / 2K. Please add Requesty-specific size parsing/validation and reject unsupported values instead of silently changing aspect ratio/resolution. Also reconcile the product default of 2K with Requesty's documented API default of 1K.

  4. Add contract-level coverage and run the repository gates. The provider unit tests are useful, but the changed contracts still need tests for:

    • requesty and rq registry/factory lookup;
    • config-file/env defaults (base URL, model, size) and missing-key rejection;
    • providers list --json / providers show requesty --json;
    • current documented Requesty dimensions, unsupported-size rejection, malformed JSON/data URLs, and provider error propagation.

    This head has no CI/status checks. After rebasing, please run gofmt -l ., go vet ./..., make quality-gates, and GOCACHE=/tmp/md2wechat-go-build go test ./... as required by the repository workflow.

Non-blocking improvements

  • requesty.go duplicates almost the entire OpenRouter implementation. A small shared chat-image transport/data-URL/temp-file helper would reduce future drift while keeping provider-specific models, sizing, and errors separate.
  • Normalize a custom base URL before appending /chat/completions so a trailing slash does not produce //chat/completions.
  • The PR description says Requesty returns an “image URL,” while the implementation intentionally accepts only a base64 data URL. The current Requesty chat-completions docs show a data URL, so please make that wording explicit; if HTTPS image URLs are also part of the contract, handle and test them separately with bounded downloads.
  • Preserve Requesty's error message/code where possible; mapping every 403 to payment_required can hide policy/model-access failures.

The README/CONFIG/DISCOVERY/AGENT-GUIDE/IMAGE_PROVISIONERS/CHANGELOG coverage is otherwise in the right areas. Once the API IDs, sizing semantics, rebase, and contract tests are fixed, this should be straightforward to re-review.

@Thibaultjaigu

Thibaultjaigu commented Sep 11, 2026 •

Copy link
Copy Markdown
Author

Thanks for the detailed review, all of it was fair. Everything below is in 485fe2a on top of a rebase onto current main (cbc8c60, v3.5.0). GitHub now reports the PR as mergeable.

1. Rebase. Rebased onto main. The provider defaults, discovery tests, docs and release metadata that moved since 56c714e are preserved; the Requesty changes sit on top of them. The CHANGELOG entry moved to a new ## [Unreleased] section so it does not land inside 3.5.0 and the version gate still passes.

2. Model ids and payload. I checked the live catalog (GET /v1/models with a key) rather than the docs page. Neither vertex/gemini-3.1-flash-image-preview nor vertex/google/gemini-2.5-flash-image-preview is served by the router today; the docs page is stale on that point and I will get it corrected on our side. The ids that are served and return images are vertex/gemini-3.1-flash-image, vertex/gemini-3-pro-image and vertex/gemini-2.5-flash-image, so the registry, config default, docs and tests now all use vertex/gemini-3.1-flash-image as the default. Smoke result against the live router: vertex/gemini-3.1-flash-image with image_config: {"aspect_ratio": "16:9", "image_size": "1K"} and no modalities field returned a 1376x768 PNG as a data URL in choices[0].message.images[0].image_url.url. The request body no longer sends modalities; it sends model, messages and image_config only, and TestRequestyProvider_Generate asserts exactly that shape. For the record, google/gemini-3.1-flash-image is routable but returns zero images, which is why the old default was wrong in practice as well as on paper.

3. Size mapping. mapSizeToOpenRouter is no longer used. mapSizeToRequesty carries Requesty's own table (10 aspect ratios x 1K/2K/4K, so 1376x768 is 16:9 at 1K, 2752x1536 is 16:9 at 2K and so on) and accepts three forms: an aspect ratio alone (that ratio at 1K), a tier alone (1:1 at that tier), or an exact WIDTHxHEIGHT from the table. Anything else, including 1344x768, 1920x1080 or 3K, returns a config.ConfigError on ImageSize naming the rejected value, so nothing is silently changed. The product default is now 1:1 / 1K, matching what the API applies when image_config is omitted; config.go, the registry and the docs agree on that.

4. Coverage and gates. Added:

  • requesty / rq through NewProvider and LookupProviderMeta, plus missing key rejection and size error propagation through the factory.
  • TestLoadWithDefaultsAppliesRequestyImageDefaults for both names (base URL, model, 1:1).
  • requesty in TestBuildProviderViewsUsesCurrentRuntimeDefaults and a new providers show rq --json test checking aliases, default base URL, default model, supports_size and that exactly one supported model is flagged default.
  • All 30 documented dimensions, the tiers, the ratios, case and whitespace tolerance, and a rejection table.
  • Malformed JSON (decode_error), non data URL and broken base64 (parse_error), empty images (no_image), and every HTTP error class with the router message asserted in the user facing text.

Ran on the rebased head: gofmt -l . (clean), go vet ./..., golangci-lint 2.5.0 via go run with 0 issues (the local binary in PATH was built with go1.25 and refuses the 1.26.1 go.mod, so I used the pinned package the script falls back to), CGO_ENABLED=1 go test -count=1 ./... all green, npm pack --dry-run, make release-check OK.

Non blocking items.

  • Trailing slash on a custom base URL is trimmed before /chat/completions is appended, with a test that also checks the final URL.
  • Error handling now keeps Requesty's message and code (string or numeric) in the message. 403 is forbidden with a hint about key model and policy restrictions, 402 is payment_required, 404 is model_not_found, 400 is bad_request.
  • PR description reworded: the provider consumes a base64 data URL only, HTTPS URLs are not part of the contract and are rejected as parse_error.
  • On the shared chat image transport helper: agreed it would reduce drift between OpenRouter and Requesty. I left it out of this PR so the diff stays reviewable and does not touch OpenRouter behaviour, but I am happy to do it as a follow up if you want it.

Docs updated to the same contract: docs/IMAGE_PROVISIONERS.md (models, three accepted size forms, full dimension table, error table), docs/CONFIG.md, docs/FAQ.md, CHANGELOG.md.

Mirror the existing OpenRouter image provider to add Requesty (https://router.requesty.ai/v1),
an OpenAI-compatible router that serves image models via /chat/completions. Adds a dedicated
requesty provider, registry entry (verified image models), factory case, tests, and docs.

Signed-off-by: Thibault Jaigu <thibault.jaigu@gmail.com>
Address review feedback on the Requesty image provider.

Models: register the ids the Requesty router actually serves
(vertex/gemini-3.1-flash-image as default, vertex/gemini-3-pro-image,
vertex/gemini-2.5-flash-image) instead of the -preview ids.

Request: drop the OpenRouter modalities field and always send
image_config with aspect_ratio and image_size, matching
docs.requesty.ai/features/image-generation.

Sizes: replace the reused OpenRouter size mapping with a Requesty
specific parser. IMAGE_SIZE accepts an aspect ratio, a 1K/2K/4K tier,
or an exact WIDTHxHEIGHT from the Requesty dimension table; anything
else is a ConfigError instead of a silent substitution. Default is
1:1 at 1K, which is what Requesty applies when image_config is omitted.

Errors: keep the router message and code (string or numeric) in the
user facing message, add 403 forbidden and 402 payment_required as
separate classes, map 404 to model_not_found and 400 to bad_request,
and trim a trailing slash from a custom base URL.

Tests: contract coverage for the request body, the full dimension
table, unsupported size rejection, malformed JSON and data URLs,
every error class, requesty/rq factory and registry lookups, config
defaults for both names, and providers show rq --json.

Docs: IMAGE_PROVISIONERS.md, CONFIG.md, FAQ.md and CHANGELOG updated
to the same contract.
@Thibaultjaigu

Copy link
Copy Markdown
Author

Rebased onto current main (fce5fa3, v3.8.0). The only conflict was CHANGELOG.md, and the Requesty entry stays under [Unreleased] above 3.8.0. The code is unchanged from the last round, so the review points are still covered: vertex/gemini-3.1-flash-image as the default, no modalities field, the Requesty size table with rejection of unsupported sizes, the trailing slash trim and the separate 402/403/404 error classes.

Ran on the new head: gofmt -l . (clean), go vet ./..., GOCACHE=/tmp/md2wechat-go-build go test -count=1 ./... (all green) and make quality-gates (OK, golangci-lint 2.5.0 with 0 issues, versions aligned at 3.8.0, release-check OK).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants