Skip to main content

Providers

pureagents supports multiple LLM providers.

Available providers​

ProviderDefault modelEnvironment variable
mistralmistral-large-latestMISTRAL_API_KEY
openaigpt-5.6-lunaOPENAI_API_KEY
anthropicclaude-sonnet-5ANTHROPIC_API_KEY

Mistral (default)​

from pure_agents import Agent

# Uses MISTRAL_API_KEY from environment
agent = Agent()

# Or explicit
agent = Agent(api_key="your-mistral-key")

# Specific model
agent = Agent(model="mistral-small-latest")

OpenAI​

agent = Agent(provider="openai")

# GPT-5.6 tiers, cheapest first
agent = Agent(provider="openai", model="gpt-5.6-luna") # Default
agent = Agent(provider="openai", model="gpt-5.6-terra") # Balanced
agent = Agent(provider="openai", model="gpt-5.6-sol") # Highest capability

Anthropic​

agent = Agent(provider="anthropic")

# Claude tiers, cheapest first
agent = Agent(provider="anthropic", model="claude-haiku-4-5") # Fastest
agent = Agent(provider="anthropic", model="claude-sonnet-5") # Default
agent = Agent(provider="anthropic", model="claude-opus-5") # Agentic coding
agent = Agent(provider="anthropic", model="claude-fable-5") # Long-running agents

Any OpenAI-compatible endpoint​

Most of the ecosystem speaks the OpenAI wire format. Point base_url at it and you are done:

agent = Agent(base_url="http://localhost:11434/v1", model="llama3.3")

No API key is needed when the server does not check one. Pass api_key= when it does.

Common endpoints​

Runtimebase_urlKey
Ollamahttp://localhost:11434/v1none
LM Studiohttp://localhost:1234/v1none
vLLMhttp://localhost:8000/v1none
OpenRouterhttps://openrouter.ai/api/v1OPENROUTER_API_KEY
Groqhttps://api.groq.com/openai/v1GROQ_API_KEY
Togetherhttps://api.together.xyz/v1TOGETHER_API_KEY

Model names are yours to supply. pureagents does not ship defaults for these because their catalogues move faster than a release cycle.

Registering one by name​

If you use an endpoint more than once, give it a name:

from pure_agents import Agent, register_provider

register_provider("ollama", base_url="http://localhost:11434/v1")

agent = Agent(provider="ollama", model="llama3.3")

register_provider takes:

ParameterDefaultDescription
base_urlRequiredEndpoint root, without a trailing slash
env_varNoneEnvironment variable holding the key. Omit for a keyless local server
default_modelNoneUsed when the caller omits model=. Omit and callers must be explicit
dialect"openai""openai" or "anthropic" wire format
headersNoneExtra headers every request needs
overwriteFalseAllow replacing an existing name

Built-in providers are protected: registering over openai, mistral or anthropic needs overwrite=True, and unregister_provider refuses them outright.

Extra headers​

Some gateways want attribution headers:

agent = Agent(
base_url="https://openrouter.ai/api/v1",
model="anthropic/claude-sonnet-5",
headers={"HTTP-Referer": "https://myapp.dev", "X-Title": "My App"},
)

Headers passed to Agent win over headers set on the registered provider.

Local models for development​

Running the loop against a local model costs nothing, which makes it a good default while you iterate on prompts and tools:

import os

if os.environ.get("DEV"):
agent = Agent(base_url="http://localhost:11434/v1", model="llama3.3")
else:
agent = Agent(provider="anthropic")

Tool calling and streaming both work against Ollama, LM Studio and vLLM.

Explicit API key​

You can pass the API key directly:

agent = Agent(provider="openai", api_key="sk-...")
warning

Don't commit API keys to your repository. Use environment variables.

Custom base URL​

For self-hosted or proxy endpoints, modify the client directly:

from pure_agents.clients import LLMClient

client = LLMClient(api_key="your-key", base_url="https://your-proxy.com/v1")