Skip to main content
Point PraisonAI at any OpenAI-compatible /v1 host by setting base_url and api_key on the Agent — bare catalog model ids are fine, no provider/ prefix required.
Running the server locally? If you don’t want to hard-code the base URL or model name, use llm="local" — it discovers a running local server (Ollama, llama.cpp, LM Studio, vLLM, …) and configures itself. See the Local Model Resolver.

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 a base_url through the OpenAI-compatible client.

Configuration Options

Set these top-level Agent 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 — only base_url and the catalog id change.

Local prefix route (tool-call repair)

For a locally-served OpenAI-compatible server — LM Studio, vLLM, llama.cpp’s llama-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.
Every local prefix works the same way — swap the prefix, keep your tools:
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.
Local-server prefixes (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:
Streaming with tools keeps working on LM Studio, vLLM, and llama.cpp — the 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?

A base_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

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.
Set OPENAI_API_BASE and OPENAI_API_KEY when the host stays the same across runs. This keeps code portable across environments.
Most OpenAI-compatible chat hosts don’t serve embeddings. Configure embeddings separately — see the Embeddings docs.
PraisonAI adds the openai/ prefix internally when base_url is set. Adding it manually is harmless but unnecessary.
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.

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.