• Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
kamenxrider

kamenxrider

readwise-mastra

Public
Like
readwise-mastra
Home
Code
6
app
1
jobs
1
lib
6
web
3
grounding.md
plan.md
Environment variables
6
Branches
1
Pull requests
Remixes
History
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
grounding.md
Code
/
grounding.md
Search
…
Viewing readonly version of main branch: v29
View latest version
grounding.md

Your earlier direction was mostly right (OpenAI-compatible chat completions + Bearer key), but the correct canonical host/endpoint from paste.txt is https://gen.pollinations.ai/v1/chat/completions (and /openai is explicitly marked legacy/deprecated).[1] So Townie should implement Pollinations against gen.pollinations.ai by default, keep the base URL configurable, and add model discovery + fallback selection.[2][1]

Townie: Pollinations integration (corrected)

  1. Set defaults to:
  • POLLINATIONS_BASE_URL = "https://gen.pollinations.ai"[1]
  • POLLINATIONS_CHAT_PATH = "/v1/chat/completions"[1]
  • Authorization: Bearer ${POLLINATIONS_TOKEN} header.[1]
  1. Do not use /openai except as an emergency fallback, because the docs say it’s a legacy endpoint and recommends /v1/chat/completions instead.[1]

  2. Use secret keys (sk_) only on the server side (Val Town env var), because publishable keys are beta and explicitly warned against for production client-side use.[2][1]

Townie: model selection + fallbacks (cheap but good)

Pollinations explicitly supports model discovery endpoints, so Townie should implement runtime discovery and pick models based on capabilities and pricing metadata instead of hardcoding names.[1]

Implement discovery (required)

  • On startup (and daily), call GET https://gen.pollinations.ai/v1/models to get available OpenAI-compatible text models.[1]
  • Also call GET https://gen.pollinations.ai/text/models to get richer model metadata including pricing and capability flags like tools, reasoning, and context_window.[1]
  • For images, call GET https://gen.pollinations.ai/image/models to enumerate image models and pricing.[1]

Default text model + fallbacks (recommended)

Use this ordered list, but only if each model exists in /v1/models (otherwise skip it):[1]

  1. Primary: gemini (cheap/good default).[1]
  2. Fallback 1: openai (broad compatibility baseline per examples).[1]
  3. Fallback 2: gemini-large (use when you need higher quality / harder planning).[1]
  4. Optional: gemini-search only if you intentionally add “web search” features, since it’s described as having google_search enabled.[1]

Townie should store the chosen primary/fallback model IDs in SQLite (or config) after discovery so requests don’t depend on discovery every time.[2][1]

When to use which (simple policy)

  • Inbox triage + tagging suggestions: use primary (gemini) to keep costs low.[1]
  • AI “plan” generation for large batches (projects/apply rules): allow escalation to gemini-large when the task is complex or the first attempt fails validation.[1]
  • If Pollinations returns model errors, automatically retry with the next fallback in order.[1]

Townie: image generation (optional but easy win)

Pollinations supports image generation at GET https://gen.pollinations.ai/image/<prompt>?model=flux with Bearer auth, so Townie can implement a /api/image/cover endpoint (or similar) for project cover images or “visual summaries.”[1] Also implement image model fallback using /image/models rather than hardcoding flux everywhere (but flux is a fine default).[1]

Readwise + Val Town reminders (keep as-is)

Readwise Reader API auth stays Authorization: Token XXX (separate from Pollinations), stored in Val Town env vars.[3][2] Keep Pollinations and Readwise tokens server-side only (Val Town environment variables), because Val Town endpoints are public-by-URL unless you add auth.[2]

If you want, I can give Townie an exact “decision function” (TypeScript) that consumes /text/models and picks the cheapest model that still has tools=true (if you need tool calling) vs tools=false (for pure summarization).[1]

Citations: [1] paste.txt
[2] llms-full-valtown.txt
[3] Reader API

FeaturesVersion controlCode intelligenceCLIMCP
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
© 2026 Val Town, Inc.