Feature Request: Top-level generateImage() and embed() activity functions
#284
threepointone
started this conversation in
Ideas
Replies: 2 comments 3 replies
-
|
Isn't there already a generateImage() function? Could you please clarify what are you asking for |
Beta Was this translation helpful? Give feedback.
3 replies
-
|
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
(written with some help from opus, as obvious)
Summary
TanStack AI has great adapter infrastructure for image generation and embeddings —
BaseImageAdapter, provider-specific adapters likeOpenAIImageAdapter,GeminiImageAdapter,GrokImageAdapter, and embedding support in several providers. But there's no top-level activity function to actually use them, the waychat()works for text adapters.We'd love to see
generateImage()andembed()(or similar) added as first-class activity functions alongsidechat()andsummarize().Prior art: Vercel AI SDK
The Vercel AI SDK already has this exact pattern and it works really well. Their core API includes:
generateImage()— top-level function: takes a model + prompt, returns generated imagesembed()— single value embeddingembedMany()— batch embeddingstranscribe()— audio transcriptiongenerateSpeech()— text-to-speechexperimental_generateVideo()— video generationTanStack AI already follows a very similar architecture (top-level activity functions + provider adapters), so the shape of these APIs would map naturally. For example, the Vercel
embed()API is clean and simple:The TanStack equivalent would look something like:
Why this matters to us
We're building
@cloudflare/tanstack-ai(PR #389) — the canonical package for using TanStack AI with Cloudflare Workers AI and AI Gateway. It wraps all the TanStack AI provider adapters to route through Cloudflare's infrastructure.We've written Workers AI adapters for image generation and embeddings that work at the low level (calling Cloudflare's
env.AI.run()binding), but we're currently holding them back from our public API because there's no TanStack AI activity function to plug them into.Right now, users of our package can do:
But for images and embeddings, there's no equivalent:
What exists today in TanStack AI
The building blocks are already in place:
BaseImageAdapteris available in@tanstack/ai/adapters(landed in 0.4.2)OpenAIImageAdapter,GeminiImageAdapter,GrokImageAdapterall existOpenAITranscriptionAdapter,OpenAITTSAdapter,OpenAIVideoAdapterexistchat()andsummarize()patterns provide a clear blueprintIt's really just the orchestration layer (the top-level functions) that's missing.
What we're requesting
generateImage()A top-level activity function for image generation, analogous to
chat():embed()/embedMany()Top-level activity functions for embeddings:
transcribe(),generateSpeech(),generateVideo()For completeness, given that the adapter classes already exist:
React hooks (stretch goal)
Eventually, hooks in
@tanstack/ai-react(likeuseGenerateImage()) would be amazing, following theuseChat()pattern.We're happy to help
We'd love to contribute implementation work on this if that'd be useful. We have a good understanding of the adapter pattern from building our Cloudflare wrappers, and we have real provider implementations (Workers AI) ready to exercise these APIs the moment they land. Happy to pair on design, write the implementation, add tests — whatever's most helpful. Just let us know how you'd like to approach it.
Beta Was this translation helpful? Give feedback.
All reactions