Skip to content

Generate bot avatars from a description - #29

Open
sousavf wants to merge 4 commits into
nikuscs:mainfrom
sousavf:feature/avatar-generator
Open

sousavf wants to merge 4 commits into
nikuscs:mainfrom
sousavf:feature/avatar-generator

Conversation

@sousavf

@sousavf sousavf commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Owners can describe an avatar and have it generated, instead of only uploading an image or picking an orb or emoji. Generation uses Pi's image models through the provider logins Orbs already keeps, so adding an OpenRouter key in Settings, under Providers, is enough. No local server or extra setting is needed.

  • Picker: a Generate button beside Upload opens a popover for the description (Cmd/Ctrl+Enter submits). Below the field it names the model in use and notes that the provider charges per image. Without an image model, the popover says to add a provider with image models in Settings, under Providers.
  • Model: prefers OpenRouter's google/gemini-2.5-flash-image, otherwise the first model from models.getAvailableOfType('image').
  • Server: avatars.generate calls models.generateImages() with a portrait prompt and a 180s timeout, takes the first image, and saves it through the existing avatar image store as the usual 512px webp. avatars.generator returns the model that will be used, or null.
  • Freshness: signing in or out of a provider refreshes avatars.generator, so Generate becomes available right away.
  • Errors: a new non-reportable UPSTREAM_UNAVAILABLE (502) for no image model, a provider error or timeout, or an unusable image. The prompt is never logged.

Testing

  • bun run check and bun run lint pass.
  • Checked the no-model state in the web app.
  • Not yet tested end to end with a real image model: this machine has no OpenRouter key.
  • Web only; the iOS picker has Upload but no Generate yet.

Screenshots

Without an image model (sidebar names are demo text):

Generate without an image model

A local Automatic1111-compatible image server, such as Draw Things, paints
the portrait; its URL is a daemon setting in General settings.
@sousavf
sousavf requested a review from nikuscs as a code owner November 8, 2026 09:38
@nikuscs

nikuscs commented Nov 8, 2026

Copy link
Copy Markdown
Owner

Hey Vasco, nice work on this one, generating avatars from a description is a great touch. I pushed a few fixes on top (popover close no longer drops a pending result, generator URL keeps its path prefix, probe needs a real model, storage errors keep their cause).

Bigger thought though: running Automatic1111 locally and pointing a URL at it feels a bit too nerdy for most owners. Pi already does image generation for us:

  • ModelRuntime has getAvailableOfType('image') and generateImages(), using the same provider logins we already keep in Pi's auth store.
  • Today that means OpenRouter (e.g. google/gemini-2.5-flash-image, black-forest-labs/flux.2-pro), so adding an OpenRouter key in Providers is enough.
  • When pi-ai adds images for the GPT subscription, it should just show up without changes on our side.

Could you rework it that way? Roughly: show Generate only when an image model is available (otherwise a hint to add an image provider in Settings → Providers), call models.generateImages() with the first available image model, and save the result through the existing avatar store. That also lets us drop the generator URL setting, the probe and the HTTP client. Happy to help if you want to pair on it, and feel free to push back if I'm missing a reason to keep the local server.

Generate uses the first available image model from the providers signed
in through Pi, such as OpenRouter, so no local server or URL setting is
needed. Without an image model, the popover explains how to add one.
…changes

Generate prefers OpenRouter's Gemini 2.5 Flash Image, falling back to the
first available image model, and the popover names the model in use.
Signing in or out of a provider refreshes whether Generate is available.
@sousavf

sousavf commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, that's a much better fit than a local server. Reworked along your outline in 3b3e331 and 7fb205f: Pi's image models, saved through the avatar store, with the URL setting, probe and HTTP client gone.

A few calls I made, happy to change any of them:

  • Hint placement: Generate always shows, and its popover holds the "add an image provider" hint when there's no image model. Otherwise the hint would need its own spot in every bot form.
  • Model choice: rather than the first image model, it prefers google/gemini-2.5-flash-image and falls back to the first, since some of the 63 OpenRouter image models cost a lot more. The popover names the model in use.
  • Freshness: signing in or out of a provider now refreshes whether Generate is available.

One follow-up, not for this PR: I'd still like a free or local route. Pi only has the OpenRouter image API today, so that would mean a local images provider, ideally in pi-ai. Does that sound worth raising there?

I haven't run it against a real image model yet, since I have no OpenRouter key here.

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