Skip to content

feat(providers): optional AI Horde API key and live image catalog - #10542

Merged
diegosouzapw merged 4 commits into
cheaper-inference:release/v3.8.50from
pageragatz:feat/aihorde-optional-key-image-catalog
Aug 18, 2026
Merged

diegosouzapw merged 4 commits into
cheaper-inference:release/v3.8.50from
pageragatz:feat/aihorde-optional-key-image-catalog

Conversation

@pageragatz

Copy link
Copy Markdown
Contributor

Summary

  • AI Horde connections can store an optional registered aihorde.net API key. Requests still work anonymously (0000000000); a saved key is used for higher queue priority (kudos).
  • Chat continues through oai.aihorde.net. Image models are discovered from Horde's live GET /v2/status/models?type=image catalog and only advertised while count > 0. Names stay the exact Horde strings.
  • POST /v1/images/generations for aihorde/<name> or horde/<name> runs Horde's native async generate/check/status flow, returns b64_json, and cancels the job on timeout or disconnect.
  • Check/Save no longer treat every key as valid. The OpenAI-compatible /v1/models probe returns 200 for any Bearer token on oai.aihorde.net; validation now uses GET /v2/find_user. An empty field is still the optional anonymous path.

Related Issues

Validation

  • Focused tests: node --import tsx/esm --test tests/unit/aihorde-image-catalog.test.ts tests/unit/aihorde-image-generation.test.ts tests/unit/aihorde-optional-api-key.test.ts tests/unit/aihorde-key-validation.test.ts
  • npm run lint (CI)
  • Production-code changes include new automated tests in this PR
  • SonarQube PR analysis is green or remaining issues documented

Tests Added Or Updated

  • tests/unit/aihorde-image-catalog.test.ts
  • tests/unit/aihorde-image-generation.test.ts
  • tests/unit/aihorde-optional-api-key.test.ts
  • tests/unit/aihorde-key-validation.test.ts

Coverage Notes

  • Catalog parser/cache, OpenAI→Horde request mapping, generation dispatch/apikey header, optional stored-key credential selection, and find_user key validation are covered by the new unit tests.
  • imageRegistry.ts stays at 999 LOC (under the 1000-line new-file cap) by sourcing live Horde models from AI_HORDE_IMAGE_PROVIDER.models.

Reviewer Notes

  • Target release/v3.8.50, not main.
  • No-auth early-return in getProviderCredentials now prefers an active stored Horde key, then the synthetic noauth fallback, and still honors #9057 allowedConnections (synthetic noauth is not returned when an allowlist is set).
  • Image generation can take several minutes (Horde volunteer queue). The handler times out at 600s and DELETEs the job.
  • Changelog fragment: changelog.d/features/00000-aihorde-optional-key-image-catalog.md (rename with the PR number after open).

pqr added 2 commits August 16, 2026 10:30
Allow a registered Horde key on the no-auth connection and send it for
chat and image jobs. List only image models that currently have workers,
and generate through Horde's native async API.

# Conflicts:
#	open-sse/config/imageRegistry.ts
#	src/app/(dashboard)/dashboard/providers/[id]/ProviderDetailPageClient.tsx
#	src/shared/constants/providers.ts
#	src/sse/services/auth.ts
The OpenAI-compatible /v1/models probe returns 200 for any Bearer token
on oai.aihorde.net, so Check always succeeded. Use Horde's /v2/find_user
lookup instead; an empty key still counts as the optional anonymous path.
@diegosouzapw

Copy link
Copy Markdown
Collaborator

The happy paths are covered, but optional-key selection bypasses connection health and new R2/catalog fetches bypass repository bounded remote-fetch protections. Add unhealthy-key fallback and timeout/abort/size/SSRF tests, then run live/VPS validation.

- Optional-key selection now honors connection health (rate-limit cooldown
  and terminal/unavailable test status) before handing a stored key back,
  rotating to the next healthy key or falling back to the anonymous no-auth
  path instead of using an unhealthy stored key.
- Route the Horde submit/check/status/cancel and catalog calls through the
  repository's bounded outbound-fetch helper (timeout, no more bare fetch())
  and route R2 image downloads through the established bounded remote-image
  fetch (SSRF host guard, DNS-rebinding pin, streaming byte cap, redirect
  limit) instead of an unbounded fetch().
- Extend the generation deadline to cover the full request lifecycle
  (catalog freshness check, submit, polling, and image download), and add a
  regression test proving that exceeding the deadline issues a DELETE
  cancel to Horde's API rather than only timing out locally.

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
diegosouzapw pushed a commit that referenced this pull request Aug 18, 2026
…owth

Three independent, already-approved provider PRs (#10542 aihorde,
#10494 gemini-web image, #10594 freepik/magnific) boarded together in
the 2026-08-18 merge-train each add a small, additive registry entry
to open-sse/config/imageRegistry.ts. None crosses the 1000-line cap
alone; combined they push it from 996 to 1019. Owner-authorized
blanket rebaseline approval for this merge batch.
@diegosouzapw
diegosouzapw merged commit b9cd5ed into cheaper-inference:release/v3.8.50 Aug 18, 2026
3 checks passed
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
…owth

Three independent, already-approved provider PRs (cheaper-inference#10542 aihorde,
cheaper-inference#10494 gemini-web image, cheaper-inference#10594 freepik/magnific) boarded together in
the 2026-08-18 merge-train each add a small, additive registry entry
to open-sse/config/imageRegistry.ts. None crosses the 1000-line cap
alone; combined they push it from 996 to 1019. Owner-authorized
blanket rebaseline approval for this merge batch.
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
…eaper-inference#10542)

* feat(providers): optional AI Horde API key and live image catalog

Allow a registered Horde key on the no-auth connection and send it for
chat and image jobs. List only image models that currently have workers,
and generate through Horde's native async API.

# Conflicts:
#	open-sse/config/imageRegistry.ts
#	src/app/(dashboard)/dashboard/providers/[id]/ProviderDetailPageClient.tsx
#	src/shared/constants/providers.ts
#	src/sse/services/auth.ts

* fix(providers): validate AI Horde keys against find_user

The OpenAI-compatible /v1/models probe returns 200 for any Bearer token
on oai.aihorde.net, so Check always succeeded. Use Horde's /v2/find_user
lookup instead; an empty key still counts as the optional anonymous path.

* chore(changelog): name the AI Horde fragment for cheaper-inference#10542

* fix(images): harden AI Horde optional-key selection and outbound fetches

- Optional-key selection now honors connection health (rate-limit cooldown
  and terminal/unavailable test status) before handing a stored key back,
  rotating to the next healthy key or falling back to the anonymous no-auth
  path instead of using an unhealthy stored key.
- Route the Horde submit/check/status/cancel and catalog calls through the
  repository's bounded outbound-fetch helper (timeout, no more bare fetch())
  and route R2 image downloads through the established bounded remote-image
  fetch (SSRF host guard, DNS-rebinding pin, streaming byte cap, redirect
  limit) instead of an unbounded fetch().
- Extend the generation deadline to cover the full request lifecycle
  (catalog freshness check, submit, polling, and image download), and add a
  regression test proving that exceeding the deadline issues a DELETE
  cancel to Horde's API rather than only timing out locally.

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>

---------

Co-authored-by: pqr <pqr@soraka.ititti.es>
Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
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