SDK
Providers & models
One agent, 20+ model providers. Route to cloud or local models and switch with a single argument.
Every model call is routed through pi-ai, so the same agent code runs on any supported provider. Choose a provider when you build the client, or override it per call.
Supported providers
| Provider id | Hosting | Auth (env var) |
|---|---|---|
anthropic | Cloud | ANTHROPIC_API_KEY |
openai | Cloud | OPENAI_API_KEY |
google | Cloud | GOOGLE_API_KEY |
mistral | Cloud | MISTRAL_API_KEY |
groq | Cloud | GROQ_API_KEY |
openrouter | Cloud | OPENROUTER_API_KEY |
ollama | Local | — |
nvidia | Local / Cloud | NVIDIA_API_KEY |
vllm | Local | — |
llamacpp | Local | — |
…and any OpenAI-compatible endpoint via base_url. Run providers.list() for the full set in your installed version.
Choosing a model
# Cloud
agent = Harnext(provider="anthropic", model="claude-opus-4-8")
# Local — no key required
local = Harnext(provider="ollama", model="llama3.2")
# Any OpenAI-compatible endpoint
custom = Harnext(
provider="openai",
model="my-model",
base_url="https://api.internal/v1",
api_key="...",
)Switching providers per stage
Run interactive work on a frontier model, then dispatch a cheap or local model for bulk steps — without rebuilding the client.
agent = Harnext(provider="anthropic", model="claude-opus-4-8")
# Heavy reasoning on the default model
plan = agent.run("Plan the migration")
# Mechanical edits on a local model
agent.run("Apply the rename across the repo", provider="ollama", model="llama3.2")Listing providers & models
from harnext import providers
providers.list() # ["anthropic", "openai", "ollama", ...]
providers.models("anthropic") # ["claude-opus-4-8", "claude-sonnet-4-6", ...]
providers.default("anthropic") # recommended model idGeneration parameters
Pass model parameters through params; unknown keys are forwarded to the provider untouched.
Python
agent.run(
"Draft the release notes",
params={"temperature": 0.2, "max_tokens": 2000},
)Local-first
Pointing at ollama, vllm, or llamacppkeeps your code on your machine — no tokens leave the host. The agent's tool surface is identical regardless of provider.