← Corpus / image-gin / prompt
Prompt — Add a New Model Provider to Image Gin
The agent-facing instruction for adding a new image-generation provider to Image Gin. Hands the work to a coding agent with the canonical blueprint to follow, the case-study prior art (Recraft, Ideogram, Magnific), and the exact files to touch — so the agent isn't reinventing the shape on every new vendor.
- Path
- prompts/Add-New-Model-Provider.md
- Authors
- Michael Staton
- Augmented with
- Claude Code on Claude Opus 4.7 (1M context)
- Tags
- Prompt · Agent-Instruction · Image-Generation · API-Integrations
Prompt — Add a New Model Provider to Image Gin
This is a prompt template for an AI coding agent. Paste it (or a customized version) into your agent session when you want to add a new image-generation provider to Image Gin.
Context to give the agent
You’re adding a new image-generation provider to Image Gin, an Obsidian plugin in
lossless-group/image-gin. The canonical pattern is documented incontext-v/blueprints/Add-New-Image-API-to-Providers.md— read that blueprint first; it’s the source of truth for the shape.The repo has reference implementations for three providers already:
- Recraft —
src/services/recraftImageService.ts,src/modals/RecraftModal.ts— generation- Ideogram —
src/services/ideogramService.ts,src/modals/IdeogramModal.ts— generation (added 2026-05-03 as the worked-example for the blueprint)- Magnific (formerly Freepik) —
src/services/freepikService.ts,src/modals/FreepikModal.ts— search/stock, distinct shape from generationUse the generation pattern (Recraft + Ideogram), not the search pattern, for any text-to-image provider.
Concrete instruction
Add
<Provider Name>as a new image-generation provider to image-gin, following the blueprint atcontext-v/blueprints/Add-New-Image-API-to-Providers.md.Provider details:
- API endpoint:
<URL>- Auth method:
<bearer token | API key in header | other>- API key env var:
<PROVIDER>_API_KEY(already added to.env)- Request shape:
<link to provider's API docs>- Response shape:
<link to provider's API docs>- Streaming or single-response:
<streaming | single>Don’t deprecate Recraft, Ideogram, or Magnific. The new provider is purely additive — separate command, separate modal, separate settings section.
Required scope (from the blueprint)
- Settings — extend
DEFAULT_SETTINGSinsrc/settings/settings.tswith a new sub-object for the provider (enabled,apiKey, model selection if multiple, any provider-specific tunables). The runtimedata.jsonmust merge cleanly overDEFAULT_SETTINGS— no field can exist at runtime without existing in defaults. - Settings UI — extend the Settings tab to render the new provider’s section. Match the visual rhythm of Recraft/Ideogram sections.
- Service —
src/services/<provider>Service.ts. Use Obsidian’srequestUrl, NOT browserfetch. Build multipart bodies by hand if the API needs uploads — seeimagekitService.tsfor the boundary pattern. - Modal —
src/modals/<Provider>Modal.tsextending the unified wide-modal pattern. Cmd/Ctrl+Enter submits. Stream responses if the API supports streaming. - Command registration — in
main.ts, add a new command that opens the modal. ID should begenerate-<provider>-image. - Type safety — strict, no
any. Useunknownand narrow at the API boundary. Type predicates (v is X) are the canonical narrowing tool. - Build cleanly —
pnpm buildmust pass with no TypeScript errors and no esbuild warnings.
Required reading
context-v/blueprints/Add-New-Image-API-to-Providers.md— canonical blueprint, treat as load-bearingcontext-v/reminders/This-is-an-Obsidian-plugin-Read-Obsidian-API-Docs.md— banned patterns (any,innerHTML,var, etc.) and review-bot rejection reasonssrc/services/recraftImageService.ts— reference implementation; copy its shape, not its provider-specific detailssrc/modals/IdeogramModal.ts— reference modal implementation
What the agent should not do
- Don’t introduce new dependencies. Use Node built-ins and Obsidian’s
requestUrl. Specifically: noaxios, nonode-fetch, nojs-yaml. - Don’t refactor adjacent providers. Recraft and Ideogram are out of scope unless the new provider’s pattern reveals a shared abstraction worth extracting — and even then, raise it as a separate question, don’t act on it.
- Don’t change the wide-modal layout. New providers slot into the existing pattern.
- Don’t bump the plugin’s version in
manifest.jsonby hand —pnpm versionhandles that.
Validation before declaring done
pnpm buildexits 0.pnpm devrunning, plugin loaded in a test vault, the new command appears in the command palette.- Modal opens, settings render, an actual API call returns and writes a file.
- The other three providers (Recraft, Ideogram, Magnific) still work — quick smoke test on each.
Provider-specific notes (when the new provider is…)
Google Gemini Imagen
Endpoint shape: POST https://generativelanguage.googleapis.com/v1beta/models/imagen-3.0-generate-001:generateContent (or current equivalent — see https://ai.google.dev/gemini-api/docs/imagen). Auth via key=<API_KEY> query parameter or x-goog-api-key header. Returns base64-encoded PNG bytes inline in the response — service module needs to decode and write to vault.
Stability AI / SDXL
Endpoint shape: POST https://api.stability.ai/v2beta/stable-image/generate/<engine>. Auth via Authorization: Bearer <key>. Multipart form for inputs; response is binary image bytes directly.
Flux
Endpoint shape varies by hosted provider (Replicate, BFL direct, etc.). Pick one host and document which.