skills/ai-agent-development/agent-llm-providers/SKILL.md
Guides implementation of swappable LLM provider interfaces for AI agents. Covers open-source (Ollama, LlamaCPP) and closed-source (OpenAI, Gemini) backends via abstract base classes and factory patterns. Use when designing configurable or multi-provider agent systems.
npx skillsauth add pkuppens/pkuppens agent-llm-providersInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Patterns for abstracting LLM backends behind a common interface so agents can swap between providers without changing application code. Covers provider abstraction, factory pattern, configuration, and the trade-offs of each backend.
Define an abstract interface that all providers implement:
from abc import ABC, abstractmethod
from dataclasses import dataclass
@dataclass
class LLMResponse:
content: str
model: str
input_tokens: int
output_tokens: int
class BaseLLMProvider(ABC):
@abstractmethod
async def complete(
self,
messages: list[dict[str, str]],
temperature: float = 0.7,
max_tokens: int = 1024,
) -> LLMResponse:
...
@abstractmethod
async def complete_with_tools(
self,
messages: list[dict[str, str]],
tools: list[dict],
temperature: float = 0.7,
) -> LLMResponse:
...
def create_llm_provider(backend: str, **kwargs) -> BaseLLMProvider:
providers = {
"ollama": OllamaProvider,
"openai": OpenAIProvider,
"gemini": GeminiProvider,
"llamacpp": LlamaCPPProvider,
}
if backend not in providers:
raise ValueError(f"Unknown backend: {backend}. Available: {list(providers)}")
return providers[backend](**kwargs)
LLM_BACKEND=ollama
LLM_MODEL=llama3.2
LLM_BASE_URL=http://localhost:11434
LLM_API_KEY= # empty for local providers
LLM_TEMPERATURE=0.7
LLM_MAX_TOKENS=2048
| Provider | Interface | Models | GPU required | Strengths | |----------|-----------|--------|-------------|-----------| | Ollama | REST API (OpenAI-compatible) | Llama, Mistral, Gemma, Phi, Qwen | Recommended | Easy setup, model management, OpenAI-compatible API | | llama.cpp | C++ library, Python bindings | GGUF format models | Optional (CPU possible) | Lightweight, quantisation support, runs on CPU | | vLLM | REST API (OpenAI-compatible) | HuggingFace models | Yes | High throughput, production-grade serving | | TGI (HuggingFace) | REST API | HuggingFace models | Yes | HuggingFace ecosystem integration |
| Provider | SDK | Key models | Strengths |
|----------|-----|------------|-----------|
| OpenAI | openai Python, C# SDK | GPT-4o, GPT-4o-mini, o3 | Widest tool-calling support, mature SDK |
| Google Gemini | google-genai Python SDK | Gemini 2.5 Pro/Flash | Multimodal, large context window (1M tokens) |
| Anthropic | anthropic Python SDK | Claude Sonnet/Opus | Strong reasoning, extended thinking |
| Azure OpenAI | openai with Azure config | Same as OpenAI | Enterprise compliance, VNet integration |
Semantic Kernel provides built-in provider abstraction:
// Swap providers by changing the service registration
var builder = Kernel.CreateBuilder();
// OpenAI
builder.AddOpenAIChatCompletion("gpt-4o", apiKey);
// Azure OpenAI
builder.AddAzureOpenAIChatCompletion("gpt-4o", endpoint, apiKey);
// Ollama (OpenAI-compatible endpoint)
builder.AddOpenAIChatCompletion("llama3.2", apiKey: null,
httpClient: new HttpClient { BaseAddress = new Uri("http://localhost:11434/v1") });
testing
Syncs remote default branch locally (checkout, fetch --prune, pull) and returns to the previous branch when it still exists. Reports stashes and worktrees not yet handled. Use when the user asks to sync main, update default branch, fetch/pull origin, or run /sync-branch.
tools
Creates, queries, updates, and links Azure Boards work items via az boards CLI. Use when filing ADO work items, running WIQL queries, or setting area path, iteration, tags, and assignee.
tools
Creates, reviews, and completes Azure Repos pull requests and branch policies via az repos CLI. Use when opening ADO PRs, setting required reviewers, or configuring build validation policies.
development
Guides Azure Pipelines YAML structure, build validation on PRs, and staged deployment with environments and approvals. Use when authoring azure-pipelines.yml or configuring CI/CD on Azure DevOps.