Skip to content

feat(providers): google/ model prefix, vendor routes on unknown prefixes, doctor ai@5 hint - #662

Merged
LinuxDevil merged 1 commit into
mainfrom
feat/provider-google-prefix
Oct 16, 2026
Merged

LinuxDevil merged 1 commit into
mainfrom
feat/provider-google-prefix

Conversation

@LinuxDevil

Copy link
Copy Markdown
Owner

Problem

resolveProvider('google/gemini-2.5-flash') and createAgent({ model: 'google/...' }) threw unrecognized provider 'google', because the only prefixes were openai, anthropic, openrouter, ollama, pi and mock. Competing SDKs accept any provider/model string. For any other vendor the error listed the prefixes and stopped there, without saying how to reach that vendor. Separately, an installed ai@5 (not supported) only got the generic peer-range failure in lousho doctor.

Fix

  • google/ prefix: new GoogleProvider, built the same way as the OpenAI and Anthropic providers. It lazily loads the optional peer @ai-sdk/google through loadOptionalPeer(), pinned per ai major: ^1.2.0 for ai 4, ^3.0.0 for ai 6, ^4.0.0 for ai 7. It reads GOOGLE_GENERATIVE_AI_API_KEY. The peer is wired into:
    • the providerSpec PROVIDERS table, so it gets the missing-key error, the per-major install hint for LOUSHO_PEER_MISSING, env detection and the doctor checks for pairing and key
    • doctor --ping, which sends the key in the x-goog-api-key header
    • built-in registration, the barrel export, lousho init --provider google, specToAgent and the node-server provider detection
    • typings/optional-peers.d.ts, peerDependencies + peerDependenciesMeta.optional, and fallow ignoreDependencies
    • the Worker builds: in the /worker entry it is shimmed with a coded failure, and in the cloudflare adapter it stays external. Google is not a Worker provider, the same as ollama and pi.
  • Unknown prefix: when nothing is a near-miss, the error now lists other ways to reach the vendor: openrouter/<vendor>/<model>, pi/<vendor>/<model> (only when pi-ai serves that vendor; a test checks the list against pi-ai's getProviders()), and createAgent({ provider: fromAiSdk(<vendor>('<model>')) }). A vendor that pi serves is never shown as a typo, so xai is no longer read as "did you mean pi". The [LOUSHO_PROVIDER_UNKNOWN] … (docs/errors.md#lousho_provider_unknown) help line is still appended, and its hint now mentions these routes.
  • ai 5: lousho doctor fails peer.ai with "AI SDK v5 is not supported" and an upgrade hint: move to ai 6 or 7 and the matching @ai-sdk/* major. The README Installation section now states the supported ai majors.
  • Docs: providers.md (Google, a new "Vendors without a prefix" section, the pairing table, the file-parts table, the ai 5 doctor note), installation.md pairing table, errors.md, CHANGELOG, and regenerated llms.txt, llms-full.txt and the api reports.

Verification

  • npx tsc --noEmit, npm run lint, npm run build (including the Worker entry): clean
  • npm run api:check, npm run docs:llms:check: up to date
  • npx vitest run src/cli src/providers src/spec src/deploy src/createAgent.test.ts src/utils: 1599 passed, 4 skipped. The new tests cover:
    • the resolver with the peer mocked (GoogleProvider.test.ts) and absent (missingPeer.test.ts, the resolveProvider install hint)
    • the unknown-prefix messages: OpenRouter only, OpenRouter + pi, and factory-name sanitizing
    • the doctor checks for ai 5, @ai-sdk/google pairing and the Google ping
    • the init templates for google, and the Worker shim
  • npm run typecheck:tests reports one error that already exists on main (src/tools/mcp/loadMcpTools.test.ts), not in this change.

🤖 Generated with Claude Code

…xes, doctor ai@5 hint

- `google/<model>` resolves to a new GoogleProvider backed by the optional
  peer @ai-sdk/google (^1.2.0 / ^3.0.0 / ^4.0.0 for ai 4 / 6 / 7), reading
  GOOGLE_GENERATIVE_AI_API_KEY. Covered by init, doctor (pairing, key,
  --ping), the missing-peer hint, and the Worker entry shim.
- An unknown prefix now suggests openrouter/<vendor>/<model>,
  pi/<vendor>/<model> when pi serves the vendor, and fromAiSdk().
- `lousho doctor` fails an installed ai 5 with an upgrade hint; README
  notes the supported ai majors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@LinuxDevil
LinuxDevil force-pushed the feat/provider-google-prefix branch from a26177e to adfb9cc Compare October 16, 2026 20:50
@LinuxDevil
LinuxDevil merged commit bfa54e2 into main Oct 16, 2026
2 of 8 checks passed
@LinuxDevil
LinuxDevil deleted the feat/provider-google-prefix branch October 16, 2026 20:51
LinuxDevil added a commit that referenced this pull request Oct 16, 2026
#662 added a Google ping target with a 'base' field while #663 changed
PingTarget to a full 'url' plus 'checksKey', so main stopped type-checking.
Gemini's /models needs the key, so a 200 proves it.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.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.

1 participant