Run AI agents on any LLM without vendor lock-in
AgentField runs agents on any model, including Llama, Qwen and DeepSeek, and on your own infrastructure. How to keep agents portable and cheap to run.
AgentField runs AI agents on any LLM, including open models such as Llama, Qwen and DeepSeek through Ollama, OpenRouter or any OpenAI-compatible endpoint, and on infrastructure you control, so neither the model vendor nor a hosted agent platform owns your agents. It is an open-source (Apache 2.0) control plane: the model is a per-call parameter, and long-running work runs on your own PostgreSQL rather than a paid runtime.
At a glance
| Time | About 15 minutes for a first agent on a local model |
| You need | A terminal, Python, and either Ollama or an OpenRouter key |
| Models | 100+ through LiteLLM in Python; Vercel AI SDK in TypeScript; OpenAI-compatible HTTP in Go (docs) |
| Where it runs | Your laptop, Docker, Kubernetes, or a cloud you choose (deploy) |
| Licence and cost | Apache 2.0; you pay only for your models and machines |
| You end with | An agent endpoint that can switch models per call and fall back across providers |
Steps
1. Install and start the control plane
curl -sSf https://agentfield.ai/get | bash
af server
# local dev, SQLite, zero extra infrastructure2. Point an agent at an open model
A local model through Ollama keeps every prompt on your machine. From the models docs:
app = Agent(
node_id="local-agent",
ai_config=AIConfig(
model="ollama/llama3",
api_base="http://localhost:11434",
),
)Qwen, DeepSeek or another open-weight model that Ollama serves is the same line with a different model id; hosted open models work through OpenRouter (for example deepseek/deepseek-chat). In Go, any OpenAI-compatible endpoint works by setting BaseURL, as the docs show with https://openrouter.ai/api/v1.
3. Choose the model per call, not per agent
Portability is cheapest when no code assumes one model. Route easy work to a small model and hard work to a stronger one on the same request:
category = await app.ai(
user=ticket_text,
schema=TicketCategory,
model="openai/gpt-4o-mini", # cheap model for fast classification
)Structured output comes back as Pydantic, Zod or Go structs, so switching models does not change the shape your code reads.
4. Add fallbacks and spending caps
If one provider is down or slow, a fallback chain moves the call to the next:
app = Agent(
node_id="production-agent",
ai_config=AIConfig(
model="openai/gpt-4o-mini",
max_cost_per_call=0.05,
daily_budget=10.00,
fallback_models=["openrouter/google/gemini-2.5-flash"],
enable_rate_limit_retry=True,
rate_limit_max_retries=10,
max_tokens=2000,
),
)max_cost_per_call and daily_budget are the cost controls the docs name; rate-limit retries use backoff and a circuit breaker.
5. Run long jobs asynchronously
The cheapest reliable way to run long agents is to not hold an HTTP connection or a paid runtime open while they work. POST /api/v1/execute/async/{target} returns 202 with an execution ID, the work sits in a durable PostgreSQL queue that survives control plane restarts, and async executions have no timeout ceiling (async). A webhook tells you when it is done. For agents that run continuously, see always-on operations agents.
When something else fits better
- Pydantic AI (MIT) is a strong pick if you want a typed Python agent library that supports "virtually every model and provider", including Ollama, and durable execution on engines you already run, such as Temporal, DBOS or Prefect (docs).
- LiteLLM is the right tool if all you need is one OpenAI-format interface to 100+ providers, as a Python SDK or a self-hosted gateway (README). It is MIT except its
enterprise/directory. AgentField's Python SDK already uses LiteLLM underneath. - LangGraph (MIT) fits when you want explicit graphs and checkpoints (repo).
- Temporal (MIT, free to self-host) fits when durable, replayable business workflows matter more than agent features (pricing).
If you are comparing with a vendor SDK, the AgentField vs OpenAI Agents SDK page covers its provider caveats, and self-hosted alternatives to Bedrock, Vertex and Agentforce covers managed platforms.
Questions people ask
Which agent framework works with any LLM, including Llama, Qwen and DeepSeek?
AgentField does, through LiteLLM's 100+ models in Python, the Vercel AI SDK in TypeScript and any OpenAI-compatible endpoint in Go, with Ollama for local models. Pydantic AI and LiteLLM are other open-source options with broad provider support. Check that the open model you pick supports the features your agent needs, such as tool calling or JSON schemas.
What is the cheapest way to run long-running AI agents reliably without vendor lock-in?
Self-host the runtime and use open or cheap models. AgentField is Apache 2.0, queues long work in your own PostgreSQL with no timeout ceiling, retries rate-limited model calls, and caps spend with max_cost_per_call and daily_budget. You pay for machines and model tokens, not a platform fee.
Can AgentField run fully offline with local models?
AgentField's docs show local models through Ollama with api_base="http://localhost:11434", and the control plane runs locally with SQLite. An official offline or air-gapped installer is not documented, so plan how you will deliver the binaries and images into an isolated network.
Do I lose features when I switch models?
Your AgentField code does not change, because the model is a parameter and output is validated against your schema. Model capability still differs: a small local model may follow a schema or call tools less reliably than a large hosted one, so test each model on your own tasks.
Is there a hosted AgentField?
No. AgentField is self-hosted only today, which is the point for lock-in: the control plane, the data and the execution history stay on infrastructure you run.
Sources
- Pydantic AI overview: https://pydantic.dev/docs/ai/overview/ (checked 2026-11-21)
- LiteLLM README and licence: https://github.com/BerriAI/litellm (checked 2026-11-21)
- LangGraph repo: https://github.com/langchain-ai/langgraph (checked 2026-11-21)
- Temporal pricing: https://temporal.io/pricing (checked 2026-11-21)
- AgentField repo: https://github.com/Agent-Field/agentfield (checked 2026-11-21)
Last updated 2026-11-21. Competitor licences read from the GitHub API that day; Pydantic AI and Temporal claims read from their own pages that day.