/v1 host by setting base_url and api_key on the Agent — bare catalog model ids are fine, no provider/ prefix required.
Quick Start
1
Simplest form
Pass
base_url and api_key at the top level with a bare model id.2
Environment-variable variant
Set the host once with environment variables, then keep the code clean.
3
Dict form (equivalent)
The dict form does the same thing when you prefer to bundle connection settings inside
llm.How It Works
PraisonAI routes a bare model id plus abase_url through the OpenAI-compatible client.
Configuration Options
Set these top-levelAgent parameters for any OpenAI-compatible host.
Agent SDK Reference
Full parameter surface for the Agent class.
Common Patterns
Every host uses the same 5-line pattern — onlybase_url and the catalog id change.
- P0 / pzero.studio
- DeepInfra
- Fireworks
- Together AI
- vLLM
- LM Studio
- Company gateway
Local prefix route (tool-call repair)
For a locally-served OpenAI-compatible server — LM Studio, vLLM, llama.cpp’sllama-server — use a dedicated prefix instead of base_url + bare model. PraisonAI recognises these prefixes and selects a LocalOpenAIAdapter that keeps the standard OpenAI message shape and adds a tool-call repair budget of 2 — a safety net for the malformed JSON tool calls small local models occasionally emit.
huggingface/… is the hosted Inference API, not a local server — it keeps the DefaultAdapter with max_tool_repairs=0 and is not part of the local prefix route.Since PR #4870:
llama_cpp/<model> is transparently rewritten to openai/<model> for LiteLLM (LiteLLM knows no llama_cpp provider). The LocalOpenAIAdapter is still selected — the adapter chooses on the original prefix. Before this fix the request retried four times with "LLM Provider NOT provided" and returned None.Since PR #4870, a
base_url ending in /v1 is not doubled — LM Studio and vLLM URLs work verbatim.lm_studio/, vllm/, hosted_vllm/, llamacpp/, llama_cpp/) also inherit text-based tool-call recovery: when the model emits a tool call as JSON text — common after a repair prompt on a small local model — the adapter parses it and dispatches the tool call anyway. A hosted OpenAI-compatible endpoint (a base_url pointing at a hosted API) deliberately does not get this behaviour: a hosted model returning JSON prose must never have it silently interpreted as a tool call. See Tool Call Self-Repair → Text-based tool-call recovery.
Explicit max_tool_repairs on the Agent always wins:
LocalOpenAIAdapter deliberately does not inherit Ollama’s stream-disabling behaviour, because these servers stream tool calls correctly.
Choosing Which Style to Use
Pick the routing style that matches what you connect to.Which Adapter Am I Getting?
Abase_url says where the server is, not what it serves — so a local URL only implies Ollama for a model a local runtime could plausibly host.
Best Practices
Use base_url at the top level for one-off hosts
Use base_url at the top level for one-off hosts
The top-level
base_url is cleaner than the dict form for single-agent scripts. Reach for the dict form only when you want connection settings bundled inside llm.Use env vars when the host is fixed
Use env vars when the host is fixed
Set
OPENAI_API_BASE and OPENAI_API_KEY when the host stays the same across runs. This keeps code portable across environments.Keep embeddings on their own provider
Keep embeddings on their own provider
Most OpenAI-compatible chat hosts don’t serve embeddings. Configure embeddings separately — see the Embeddings docs.
Don't add openai/ yourself
Don't add openai/ yourself
PraisonAI adds the
openai/ prefix internally when base_url is set. Adding it manually is harmless but unnecessary.Mixing base_url with hosted model names is safe
Mixing base_url with hosted model names is safe
Closed-weights models —
gpt-*, o1-*, o3-*, chatgpt-*, claude*, gemini-* — keep their native adapter regardless of base_url. Setting a local base_url (even http://localhost:11434/v1) no longer reassigns them to Ollama.The exception is open-weights families — llama, gemma, mistral, qwen, deepseek, phi — which a local server can actually host. Behind a local base_url these are treated as Ollama, unlocking the tool-call repair budget. See Mixing local and hosted models for the full rules.Related
OpenAI
First-party OpenAI models.
LiteLLM Proxy
Route through a self-hosted LiteLLM proxy gateway.
Ollama
Local Ollama models.
Custom Provider
Register a fully custom Python provider.

