ai-infrastructure-hugg…
Hugging Face Inference SDK patterns for TypeScript/Node.js — InferenceClient setup, chat completion, text generation, streaming,…
Local LLM inference with the Ollama JavaScript client -- chat, streaming, tool calling, vision, embeddings, structured output, model management, and OpenAI-compatible endpoint
Claude Code
$ npx -y skills add agents-inc/skills --skill ai-infrastructure-ollama --agent claude-code
Codex
$ npx skills add agents-inc/skills --skill ai-infrastructure-ollama -a codex -y
Cursor
$ npx skills add agents-inc/skills --skill ai-infrastructure-ollama -a cursor -y
Gemini CLI
$ npx skills add agents-inc/skills --skill ai-infrastructure-ollama -a gemini-cli -y
GitHub Copilot
$ npx skills add agents-inc/skills --skill ai-infrastructure-ollama -a github-copilot -y
OpenCode
$ npx skills add agents-inc/skills --skill ai-infrastructure-ollama -a opencode -y
Windsurf
$ npx skills add agents-inc/skills --skill ai-infrastructure-ollama -a windsurf -y
name: ai-infrastructure-ollama description: Local LLM inference with the Ollama JavaScript client -- chat, streaming, tool calling, vision, embeddings, structured output, model management, and OpenAI-compatible endpoint
> **Quick Guide:** Use the `ollama` npm package to run LLMs locally. Use `ollama.chat()` for conversations and `ollama.generate()` for single prompts. Enable streaming with `stream: true` and iterate with `for await`. Use `format` with a JSON schema (via `zodToJsonSchema`) for structured outputs. Use `tools` array for function calling. Use `ollama.embed()` for embeddings. Models run on your machine -- no API keys required for local use, but be aware of model loading time and memory usage.
---
<critical_requirements>
**(You MUST use `ollama.chat()` for conversations and `ollama.generate()` for single-prompt completions -- they have different parameter shapes)**
**(You MUST handle model loading delays -- the first request after a model is loaded takes significantly longer due to model initialization)**
**(You MUST use `zodToJsonSchema()` from `zod-to-json-schema` for structured outputs -- do NOT manually construct JSON schemas)**
**(You MUST accumulate streamed `thinking`, `content`, and `tool_calls` fields to maintain conversation history in multi-turn interactions)**
**(You MUST never assume a model is already pulled -- check with `ollama.list()` or handle errors from missing models gracefully)**
</critical_requirements>
---
**Auto-detection:** Ollama, ollama, ollama.chat, ollama.generate, ollama.embed, ollama.pull, ollama.list, ollama.show, ollama.delete, ollama.ps, ollama.abort, ollama.create, keep_alive, zodToJsonSchema, OLLAMA_HOST, llama3, mistral, qwen, gemma, phi, deepseek, local LLM
**When to use:**
**Key patterns covered:**
**When NOT to use:**
---
---
<philosophy>
The Ollama JavaScript library is a **thin client over Ollama's local REST API** (default `http://127.0.0.1:11434`). It provides direct access to locally-running open-source LLMs with zero cloud dependencies.
**Core principles:**
1. **Local-first** -- Models run on your hardware. No API keys required for local use, complete data privacy, no per-token costs. Trade-off: you need sufficient GPU/CPU memory. 2. **Simple API** -- `ollama.chat()` and `ollama.generate()` are the two primary methods. The default import is a pre-configured singleton client; create custom instances with `new Ollama()` for non-default hosts. 3. **Streaming by default in REST, opt-in in SDK** -- The REST API streams by default. The SDK returns full responses by default; set `stream: true` to get an `AsyncGenerator`. 4. **Model-agnostic** -- The same API works with any Ollama-supported model (Llama, Mistral, Qwen, Gemma, Phi, DeepSeek, etc.). Model capabilities (vision, tool calling, structured output) depend on the model. 5. **OpenAI-compatible** -- Ollama exposes `/v1/chat/completions` and `/v1/embeddings` endpoints, allowing the OpenAI SDK to connect with `baseURL: 'http://localhost:11434/v1'`.
</philosophy>
---
<patterns>
The default import is a pre-configured singleton pointing to `http://127.0.0.1:11434`.
// lib/ollama.ts -- default client (most common)
import ollama from "ollama";
// Use directly -- connects to localhost:11434
const response = await ollama.chat({
model: "llama3.1",
messages: [{ role: "user", content: "Hello" }],
});// lib/ollama.ts -- custom client for non-default host
import { Ollama } from "ollama";
const ollama = new Ollama({
host: "http://192.168.1.100:11434",
});
export { ollama };**Why good:** Minimal setup, default client requires zero configuration, custom client for remote servers
// BAD: Hardcoding host inline everywhere
import { Ollama } from "ollama";
const response = await new Ollama({ host: "http://192.168.1.100:11434" }).chat({
model: "llama3.1",
messages: [{ role: "user", content: "Hello" }],The official skills marketplace for Agents Inc. 230+ skills covering everything from React and Prisma to Redis, ElevenLabs, and infrastructure tooling. Pick the skills that match your stack and install them via Claude Code. Need more control?
Hugging Face Inference SDK patterns for TypeScript/Node.js — InferenceClient setup, chat completion, text generation, streaming,…
LiteLLM proxy server setup, TypeScript client patterns via OpenAI SDK, model routing, fallbacks, load balancing, spend tracking,…
Serverless GPU compute platform for AI model deployment — web endpoints, GPU functions, model serving, and TypeScript client…
Replicate SDK patterns for TypeScript/Node.js -- client setup, predictions, streaming, webhooks, file handling, model versioning,…
Together AI SDK patterns for TypeScript — client setup, chat completions, streaming, structured output, function calling,…
LLM observability with Langfuse — OpenTelemetry-based tracing, evaluations, prompt management, datasets, and production best…
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…
Ask which skill or flow fits your situation. A router over the skills in this repo.