Provider Setup Check Skill
This app supports three AI providers, selected via the AI_PROVIDER env var. All settings
are defined in src/campaign_ai/config.py (a pydantic-settings Settings class) and
read from a .env file or environment variables.
Supported providers
AI_PROVIDER | Required env vars | Default model |
|---|
openai | OPENAI_API_KEY | gpt-5.4-mini (override with OPENAI_MODEL) |
openrouter | OPENROUTER_API_KEY | openrouter/free (override with OPENROUTER_MODEL) |
ollama | (none) | qwen3.5:9b — set OLLAMA_MODEL and OLLAMA_BASE_URL |
Web search: uses Tavily if TAVILY_API_KEY is set, otherwise falls back to DuckDuckGo (no key needed).
uv run python -c "
from campaign_ai.config import Settings
s = Settings()
print('Provider :', s.ai_provider)
print('Model :', getattr(s, s.ai_provider + '_model', 'unknown'))
print('Key set :', bool(getattr(s, s.ai_provider + '_api_key', 'ollama')))
print('Search :', 'tavily' if s.tavily_api_key else 'duckduckgo (no key)')
"
Step 2 — Validate the .env file
Check that .env exists and contains the required key for the active provider:
# Show all non-secret vars (masks values)
grep -v "API_KEY\|TOKEN" .env || echo ".env not found — copy .env.example to .env"
Reference .env.example for all available variables and their expected format.
Step 3 — Test provider connectivity
uv run python -c "
import asyncio
from campaign_ai.config import Settings
from campaign_ai.agent import get_model
from pydantic_ai import Agent
async def ping():
settings = Settings()
model = get_model(settings)
agent = Agent(model)
result = await agent.run('Reply with only the word: pong')
print('Response:', result.output)
asyncio.run(ping())
"
If this succeeds, the provider is correctly configured. If it raises:
AuthenticationError / 401 → API key is wrong or missing
ConnectionError / httpx.ConnectError → endpoint unreachable (check OLLAMA_BASE_URL for Ollama)
ValueError: Unknown AI_PROVIDER → AI_PROVIDER value is not openai, openrouter, or ollama
Step 4 — Provider-specific troubleshooting
OpenAI
- Verify key starts with
sk-
- Check model name is valid at the OpenAI platform docs
OpenRouter
- Verify key starts with
sk-or-
- Free models (e.g.
openrouter/free, google/gemini-flash-1.5) may be slow — increase HTTP_TIMEOUT (default: 120s)
- Browse available models at the OpenRouter models page
Ollama (local)
- Ensure Ollama is running:
ollama serve
- Pull the model first:
ollama pull qwen3.5:9b (or whichever OLLAMA_MODEL is set to)
- Default base URL is
http://localhost:11434/v1 — override with OLLAMA_BASE_URL
- Test directly:
curl http://localhost:11434/api/tags
Step 5 — Minimal working .env for each provider
OpenAI:
AI_PROVIDER=openai
OPENAI_API_KEY=sk-...
OpenRouter (free tier):
AI_PROVIDER=openrouter
OPENROUTER_API_KEY=sk-or-...
OPENROUTER_MODEL=google/gemini-flash-1.5
Ollama (local):
AI_PROVIDER=ollama
OLLAMA_MODEL=qwen3.5:9b
OLLAMA_BASE_URL=http://localhost:11434/v1