LL

llm-what-to-use-when

Selects the right LLM tooling (Vercel AI SDK, LiteLLM, LightLLM) based on your language and hosting environment.

Install

mkdir -p .claude/skills/llm-what-to-use-when && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/19336" && unzip -o skill.zip -d .claude/skills/llm-what-to-use-when && rm skill.zip

Installs to .claude/skills/llm-what-to-use-when

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Practical decision guide for choosing between Vercel AI SDK, LiteLLM, LightLLM, and direct provider SDKs based on runtime, deployment model, and constraints. Use when asked which LLM tooling to use for JS/TS apps, Python apps, static SPAs, or self-hosted inference.
265 chars✓ has a “when” triggerlonger than Claude Code's old 250-char listing cap (fine on current versions)
Intermediate

Key capabilities

  • Select LLM frameworks based on runtime and language
  • Configure browser-native LLM integration
  • Implement tool use and structured output
  • Deploy LiteLLM as a unified gateway proxy
  • Manage API keys for static site security

How it works

The skill maps specific project constraints,such as runtime language and hosting environment,to the most appropriate LLM library, providing configuration patterns for each.

Inputs & outputs

You give it
Project runtime, deployment model, and portability requirements
You get back
Recommended LLM library and integration strategy

When to use llm-what-to-use-when

  • Choose an LLM framework for a Node.js backend
  • Decide on an LLM approach for a static SPA
  • Select an inference server for self-hosted models
  • Compare Vercel AI SDK and LiteLLM

About this skill

LLM Inference: What To Use When

A practical guide for choosing the right library or approach depending on your runtime, use case, and constraints.

When to use this skill

Use this skill when you need to choose an LLM integration approach based on:

  • Runtime and language (JS/TS vs Python)
  • Hosting model (browser-only static site, backend app, or self-hosted inference)
  • Portability needs (single provider vs multi-provider abstraction)
  • Operational constraints (key handling, CORS, and gateway architecture)

Quick Decision Chart

Your situationUse this
Python app, any providerLiteLLM
JS/TS app with a backend (Node, Next.js, etc.)Vercel AI SDK
Static SPA (GitHub Pages, no server) + npm buildVercel AI SDK (direct browser mode)
Static SPA + no build step, vanilla JSProvider SDK direct (e.g. openai via CDN)
Hosting/serving your own open-source modelLightLLM (inference server)
Both Python app and SPA, unified gatewayLiteLLM proxy + call it from both

Option 1: Vercel AI SDK (ai)

Best for: npm-bundled SPAs, React/Vue/Svelte apps, Next.js, static sites on GitHub Pages.

Licence: MIT ✅
npm: npm install ai @ai-sdk/openai @ai-sdk/anthropic @ai-sdk/google

Strengths

  • Multi-provider with a unified API — swap providers by changing one import
  • First-class tool use and structured output (via Zod schemas with generateObject)
  • Agentic loops via maxSteps in generateText
  • Works in the browser with no backend required (direct provider calls)
  • MCP (Model Context Protocol) support in AI SDK 6+
  • Type-safe throughout

Browser / Static Site Usage

For GitHub Pages or any static host, call providers directly from the browser. The user supplies their own API key (stored in memory only, never hardcoded).

import { generateText } from 'ai'
import { createOpenAI } from '@ai-sdk/openai'
import { z } from 'zod'

const openai = createOpenAI({ apiKey: userSuppliedKey })

const { text, toolResults } = await generateText({
  model: openai('gpt-4o-mini'),
  tools: {
    rollDice: {
      description: 'Roll a die with N sides',
      parameters: z.object({ sides: z.number() }),
      execute: async ({ sides }) => Math.ceil(Math.random() * sides)
    }
  },
  maxSteps: 5,
  prompt: 'Roll a d20 and tell me if I hit AC 15'
})

Swapping to Anthropic or Gemini only changes the import and model string — all tool/structured output code stays identical.

Provider CORS Notes

ProviderDirect browser callsNotes
OpenAI✅ WorksMost permissive
Google Gemini✅ WorksGood CORS support
Anthropic⚠️ Requires flagPass dangerouslyAllowBrowser: true to createAnthropic()
Ollama (local)✅ Workslocalhost only; not useful for deployed static sites

Structured Output Example

import { generateObject } from 'ai'
import { z } from 'zod'

const { object } = await generateObject({
  model: openai('gpt-4o-mini'),
  schema: z.object({
    enemyName: z.string(),
    hp: z.number(),
    abilities: z.array(z.string())
  }),
  prompt: 'Generate a fantasy RPG enemy for a level 5 party'
})
// object.enemyName, object.hp, object.abilities are all typed

Key Caveat for Static Sites

API keys in client-side code are visible to anyone who opens DevTools. The safest UX pattern is:

  • Prompt the user to enter their own API key on first use
  • Store it in sessionStorage or in-memory only (never localStorage for sensitive keys)
  • Never commit a key to your repo

Option 2: LiteLLM (Python)

Best for: Python scripts, FastAPI/Flask backends, data pipelines, CLI tools.

Licence: MIT ✅
Install: pip install litellm

Strengths

  • Unified completion() call across 100+ providers (OpenAI, Anthropic, Gemini, Mistral, Bedrock, Ollama, etc.)
  • Drop-in OpenAI SDK replacement
  • Tool use and structured output supported
  • Can run as a proxy server (OpenAI-compatible REST API) — useful for serving SPAs too

Basic Usage

from litellm import completion

response = completion(
    model="gpt-4o-mini",          # or "claude-3-haiku", "gemini/gemini-1.5-flash", etc.
    messages=[{"role": "user", "content": "Hello!"}],
    api_key=os.environ["OPENAI_API_KEY"]
)
print(response.choices[0].message.content)

LiteLLM as a Proxy (Unified Gateway)

Run once, call from anywhere — Python apps, SPAs, curl:

litellm --model gpt-4o-mini --port 8000

Your SPA can then call http://localhost:8000/v1/chat/completions with OpenAI-format JSON. In production, deploy to a cheap VPS/container.


Option 3: LightLLM (Self-Hosted Inference)

Best for: Hosting your own open-source models (LLaMA, Mistral, Qwen, etc.) on GPU hardware.

Licence: Apache 2.0
Not for: Calling external APIs like OpenAI or Anthropic

LightLLM is an inference server, not a client SDK. You'd use it if you're running models yourself and want a fast, production-ready serving layer. Your app would then call it via HTTP, and you'd use LiteLLM or the Vercel AI SDK to talk to it.


Option 4: Direct Provider SDKs

Best for: Simple use cases, no dependency on a wrapper library, vanilla JS with a CDN import.

ProviderJS packagePython package
OpenAIopenaiopenai
Anthropic@anthropic-ai/sdkanthropic
Google Gemini@google/generative-aigoogle-generativeai

Each has tool use and structured output but in their own format. You lose portability — switching providers means rewriting call sites.


Scenarios: Your Specific Stack

Idle game SPA on timeless.github.io/idlegames

Recommended: Vercel AI SDK in direct browser mode.

npm install ai @ai-sdk/openai zod
  • User pastes their OpenAI (or Gemini) key into a settings panel
  • Call generateText or generateObject directly in JS
  • Tools let the LLM interact with game state (check resources, trigger events, etc.)
  • Structured output means you get typed JSON back, not text to parse

Python utility / automation script

Recommended: LiteLLM.

pip install litellm
  • Same completion() call regardless of provider
  • Easy to swap models for cost/speed tuning
  • Works well in async contexts with acompletion()

You want the same provider/model logic in both

Option A: Use LiteLLM as a proxy server, call it from both Python (directly) and the SPA (via HTTP). One config, all providers.

Option B: Accept that the Python and JS codebases use different libraries (LiteLLM and AI SDK respectively) but follow the same conceptual pattern — both support tools and structured output with near-identical mental models.


Summary

LibraryRuntimeMulti-providerToolsStructured outputMIT licenceBrowser-native
Vercel AI SDKJS/TS✅ (Zod)
LiteLLMPython
LightLLMPython (server)❌ (self-host only)Apache 2.0
openai (direct)JS + PythonMIT⚠️
anthropic (direct)JS + PythonMIT⚠️

Bottom line for your projects:

  • Static SPAs on GitHub Pages → Vercel AI SDK, direct browser mode, user-supplied key
  • Python apps → LiteLLM
  • Want one gateway for both → LiteLLM proxy + call it from everywhere

When not to use it

  • When self-hosting models without GPU hardware
  • When using direct SDKs for multi-provider needs

Prerequisites

Node.jsPython

Limitations

  • Direct browser calls require user-supplied API keys
  • LightLLM is restricted to self-hosted inference only

How it compares

It provides a decision framework to avoid the manual effort of evaluating and rewriting integration code when switching between providers or deployment environments.

Compared to similar skills

llm-what-to-use-when side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
llm-what-to-use-when (this skill)04moCautionIntermediate
mcp-builder1363moReviewAdvanced
stripe-integration482moNo flagsAdvanced
copilot-sdk73moReviewIntermediate

Try saying

Example prompts that trigger this skill in your AI assistant.

You might also like

mcp-builder

anthropics

Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).

136215

stripe-integration

wshobson

Implement Stripe payment processing for robust, PCI-compliant payment flows including checkout, subscriptions, and webhooks. Use when integrating Stripe payments, building subscription systems, or implementing secure checkout flows.

48165

copilot-sdk

github

Build agentic applications with GitHub Copilot SDK. Use when embedding AI agents in apps, creating custom tools, implementing streaming responses, managing sessions, connecting to MCP servers, or creating custom agents. Triggers on Copilot SDK, GitHub SDK, agentic app, embed Copilot, programmable agent, MCP server, custom agent.

763

langfuse

davila7

Expert in Langfuse - the open-source LLM observability platform. Covers tracing, prompt management, evaluation, datasets, and integration with LangChain, LlamaIndex, and OpenAI. Essential for debugging, monitoring, and improving LLM applications in production. Use when: langfuse, llm observability, llm tracing, prompt management, llm evaluation.

743

llm-application-dev

skillcreatorai

Building applications with Large Language Models - prompt engineering, RAG patterns, and LLM integration. Use for AI-powered features, chatbots, or LLM-based automation.

323

mistral-upgrade-migration

jeremylongshore

Analyze, plan, and execute Mistral AI SDK upgrades with breaking change detection. Use when upgrading Mistral SDK versions, detecting deprecations, or migrating to new API versions. Trigger with phrases like "upgrade mistral", "mistral migration", "mistral breaking changes", "update mistral SDK", "analyze mistral version".

17

Search skills

Search the agent skills registry