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 idHostingAuth (env var)
anthropicCloudANTHROPIC_API_KEY
openaiCloudOPENAI_API_KEY
googleCloudGOOGLE_API_KEY
mistralCloudMISTRAL_API_KEY
groqCloudGROQ_API_KEY
openrouterCloudOPENROUTER_API_KEY
ollamaLocal
nvidiaLocal / CloudNVIDIA_API_KEY
vllmLocal
llamacppLocal

…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 id

Generation 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.