import osfrom praisonaiagents import Agentos.environ["OPENAI_API_KEY"] = "your-api-key"agent = Agent( name="Research Assistant", instructions="You are a helpful research assistant")result = agent.start("Explain quantum computing in simple terms")
2
Use Ollama locally
Point to your local Ollama instance:
import osfrom praisonaiagents import Agentos.environ["OPENAI_BASE_URL"] = "http://localhost:11434/v1"os.environ["MODEL_NAME"] = "llama3"agent = Agent( name="Local Assistant", instructions="You are a helpful assistant running locally")result = agent.start("What are the benefits of local LLMs?")
3
Use a custom proxy / LiteLLM
Configure any OpenAI-compatible proxy:
import osfrom praisonaiagents import Agentos.environ["OPENAI_BASE_URL"] = "https://your-proxy/v1"os.environ["OPENAI_API_KEY"] = "your-proxy-key"os.environ["MODEL_NAME"] = "claude-3-sonnet"agent = Agent( name="Proxy Assistant", instructions="You are an assistant using a proxy endpoint")result = agent.start("Compare different AI models")
OPENAI_BASE_URL is the standard OpenAI SDK environment variable and has the highest precedence. Use this for all new configurations rather than the legacy OPENAI_API_BASE.
Empty string ≠ unset
An empty string value is skipped during resolution, and the next variable in precedence order is tried. To disable a variable, unset it completely rather than setting it to an empty string.
# This skips OPENAI_BASE_URL and tries OPENAI_API_BASEexport OPENAI_BASE_URL=""export OPENAI_API_BASE="https://proxy.com/v1"# This uses OPENAI_BASE_URLunset OPENAI_BASE_URLexport OPENAI_API_BASE="https://proxy.com/v1"
Use .env files for local dev
Create a .env file in your project root for local development:
# .envOPENAI_BASE_URL=http://localhost:11434/v1MODEL_NAME=llama3# OPENAI_API_KEY not needed for Ollama
Load it in your Python code:
from dotenv import load_dotenvload_dotenv()from praisonaiagents import Agent# Environment variables are now loaded
Realtime/WebSocket endpoints
For realtime features, WebSocket URLs are auto-derived from HTTP URLs. The system automatically:
Converts https:// to wss://
Strips /v1 suffix to avoid /v1/v1/realtime
Appends the appropriate realtime path
You only need to set OPENAI_BASE_URL - the realtime endpoint is handled automatically.