The Provider Pattern: How I Added Ollama Support in 50 Lines

typescript dev.to

When I started building spectr-ai, it only worked with Claude. The Anthropic SDK was hardcoded everywhere — in the analysis function, the prompt formatting, the response parsing. It worked, but it meant every user needed an Anthropic API key and an internet connection. I wanted to add Ollama support so developers could run audits locally, completely offline, using open-source models. The naive approach would have been scattering if (useOllama) checks throughout the codebase. Instead, I used the

Read Full Tutorial open_in_new
arrow_back Back to Tutorials