← Back to list

Intent-based Provider Selection: Teach GenAI PolyInfer to Pick the Best Model for the Job

What if your app could automatically pick the right AI model per user prompt — not by brittle rules, but by intent? GenAI PolyInfer’s…

Soumodip Sinha · 2025-10-02 00:32 · 0 claps · 1.6 min read
#ai #intent-recognition #genai #npm #gpt
Open on Medium ↗
Wiki topics: AI · AI · General 🏛️ · Politics

https://github.com/soumodips/genai-polyinfer

https://github.com/soumodips/genai-polyinfer

Intent-based Provider Selection: Teach GenAI PolyInfer to Pick the Best Model for the Job

What if your app could automatically pick the right AI model per user prompt — not by brittle rules, but by intent? GenAI PolyInfer’s intent feature does exactly that: tag providers with intents like chat, code, summary, or creative, and the orchestrator will prioritize providers that advertise the matching intent.

Library: https://www.npmjs.com/package/genai-polyinfer Repo: https://github.com/soumodips/genai-polyinfer Examples: https://github.com/soumodips/genai-polyinfer-sample-apps

What is intent-based selection?

Add an intent array to each provider in your config. When you call:

const res = await polyinfer("Refactor this function to use async/await", { intent: 'code' });

The orchestrator filters and prioritizes providers that advertise code. If none match, it falls back to the full provider pool. The orchestrator can also rank providers by the number of intent matches, making routing smarter over time.

Tagging providers (example)

providers: [
  { name:'openai', intent: ['chat','code','summary'] },
  { name:'anthropic', intent: ['chat','analysis'] },
  { name:'creativeai', intent: ['creative','marketing'] }
]

Calling with intent:

const res = await polyinfer("Optimize this SQL query", { intent: 'code' });

The library will prioritize providers that list code in their intent.

Creative workflows using intent routing

  1. Code-assistant + Explanation pipeline
  • intent: 'code' for edits/patches using a code-specialized model.
  • Then run intent: 'summary' to produce human-friendly explanations.

2. Quality gating & A/B

  • In parallelMode, send the same intent prompt to multiple providers and compare outputs. Keep the winner and log metrics.

3. Safety & PII pre-check

  • Pre-run intent: 'analysis' locally for PII detection before sending to cloud models.

4. Cost-aware routing

  • Tag cheaper providers for formatting/cleanup intents, premium providers for high-stakes intents.

Usage pattern (Angular, React, Vue, Node)

  • User selects “Refactor code” (maps to code).
  • App calls polyinfer(prompt, { intent: 'code' }).
  • GenAI PolyInfer returns a normalized response you can display directly.

Closing

Intent tags are small metadata with big ROI: they make routing explicit, testable and tunable. Tag providers and run an A/B week — you’ll see improvements in cost and quality fast.

Want your app to choose the best AI model automatically? Tag providers with intents in GenAI PolyInfer. npm i genai-polyinfer


메타데이터
post_id
8c3bb2ef5a82
slug
intent-based-provider-selection-teach-genai-polyinfer-to-pick-the-best-model-for-the-job-8c3bb2ef5a82
url
https://medium.com/@smdpsinha/intent-based-provider-selection-teach-genai-polyinfer-to-pick-the-best-model-for-the-job-8c3bb2ef5a82
canonical_url
https://medium.com/@smdpsinha/intent-based-provider-selection-teach-genai-polyinfer-to-pick-the-best-model-for-the-job-8c3bb2ef5a82
author_url
https://medium.com/@smdpsinha
status
ok
fetched_at
2026-07-24 16:06:45