Local-First Run

Zero-config first run that picks a model from the provider credentials you already have

The terminal CLI picks a sensible default model from whichever provider credential is present, so praisonai run "..." works without passing --model.

python
from praisonaiagents import Agent

agent = Agent(name="local-first", instructions="Answer clearly and briefly.")
agent.start("Explain black holes to a 5-year-old")
Diagram

Yes

No · TTY

No · non-TTY

praisonai run

Credential present?

Pick provider default

Suggest setup wizard

Exit with hint

Run

Quick Start

  1. Point at a local model (optional)

    Run an OpenAI-compatible endpoint such as Ollama, then export its host.

    bash
    ollama pull llama3.2 && ollama serve
    export OLLAMA_HOST=http://127.0.0.1:11434
  2. Run with no –model

    The CLI resolves a provider-appropriate default from your environment.

    bash
    praisonai run "Explain black holes to a 5-year-old"
  3. Override the endpoint (optional)

    Point at any OpenAI-compatible server without editing config.

    bash
    export OPENAI_BASE_URL=http://localhost:11434/v1
    praisonai run "Summarise today's news"
  4. Same path from the SDK

    The SDK Agent() constructor resolves the same default — no llm=, only OLLAMA_HOST set. This works from the SDK as of PR #4795.

    python
    # no OPENAI_API_KEY, no llm=; only OLLAMA_HOST is set
    from praisonaiagents import Agent
    
    Agent(instructions="local-first").start("Explain black holes to a 5-year-old")

How It Works

The CLI checks for a credential, then resolves a default model before running.

Diagram
ResolverCredentialsCLIUserResolverCredentialsCLIUserpraisonai run “…”is_configured()?yes / noresolve_default_model()provider-appropriate modelRun (one-line model notice)

is_configured() treats a run as ready when any provider key is set (env var or stored credential). resolve_default_model() then chooses the model, persisting only user-chosen models for next time.


Detection Order

The default model follows a fixed precedence.

PrioritySignalBehaviour
1Explicit --model / config / YAMLWins; persisted as the recent model
2Recent model (~/.praison/state/model.json)Reused from the last user-chosen run
3MODEL_NAME / OPENAI_MODEL_NAMEHonoured for backward compatibility
4Provider credential presentProvider-appropriate default inferred
5None of the abovegpt-4o-mini fallback

Provider-inferred default models per credential:

Credential env varDefault model
OPENAI_API_KEYgpt-4o-mini
ANTHROPIC_API_KEYanthropic/claude-3-5-sonnet-latest
GEMINI_API_KEYgemini/gemini-1.5-flash
GOOGLE_API_KEYgoogle/gemini-1.5-flash
GROQ_API_KEYgroq/llama-3.3-70b-versatile
COHERE_API_KEYcohere/command-r
OPENROUTER_API_KEYopenrouter/openai/gpt-4o-mini
OLLAMA_HOSTollama/llama3.2

When a provider-inferred default is used, the CLI prints one transparency line, for example: No model set; using ollama/llama3.2 because OLLAMA_HOST is present.


Inspect which rung won

Not sure which model your next run will use? Ask the CLI:

bash
praisonai config provenance run.model
# run.model = ollama/llama3.2
#   layer: model-resolver  source: local

The source tag maps directly to the detection-order rungs above (state:, env:MODEL_NAME, local, provider:…, fallback). See praisonai config provenance for the full tag list.


Credential Gate

The run behaves differently when no credential is found, depending on whether the terminal is interactive.

ConditionBehaviour
No credential, interactive TTYOffers the praisonai setup wizard, then continues
No credential, non-TTY / CI / JSON modePrints No API key configured. Run: praisonai setup and exits 1

Endpoint Environment Variables

Point the CLI at any OpenAI-compatible endpoint without editing config files.

VariablePurpose
OPENAI_BASE_URLBase URL for OpenAI-compatible endpoints (checked first)
OPENAI_API_BASEAlternate base-URL variable
OLLAMA_API_BASEBase URL for a local Ollama server
OLLAMA_HOSTMarks Ollama as available; infers ollama/llama3.2
MODEL_NAME / OPENAI_MODEL_NAMEForce a specific default model

Best Practices

Prefer a local model for prototyping

Set OLLAMA_HOST and let the CLI infer ollama/llama3.2. No cloud key or cost while you iterate.

Fall back to cloud with one env var

Set a provider key like OPENAI_API_KEY. The next run picks that provider’s default automatically.

Pin a model to skip inference

Pass --model or set MODEL_NAME. Both win over inference and the explicit value is remembered for later runs.

Keep CI deterministic

Export a real credential in CI. Non-interactive runs never prompt and exit 1 when nothing is configured.


Related