## 1. Configuration Setup

- [x] 1.1 Add `ROYALTY_IMAGE_PROVIDERS` config variable to `backend/config.py` with default `pixabay,unsplash,pexels,wikimedia,picsum`
- [x] 1.2 Add `PIXABAY_API_KEY` config variable to `backend/config.py`
- [x] 1.3 Add `UNSPLASH_ACCESS_KEY` config variable to `backend/config.py`
- [x] 1.4 Add `PEXELS_API_KEY` config variable to `backend/config.py`
- [x] 1.5 Update `.env.example` with new provider API key placeholders

## 2. Query Refinement

- [x] 2.1 Create `extract_image_keywords(headline: str) -> str` function in `backend/news_service.py`
- [x] 2.2 Implement stop word removal (articles, prepositions, common verbs)
- [x] 2.3 Implement keyword limit (max 5 significant words)
- [x] 2.4 Handle edge cases: empty headline, only stop words, special characters

## 3. Provider Implementations

- [x] 3.1 Create `fetch_pixabay_image(query: str) -> tuple[str | None, str | None]` function
- [x] 3.2 Implement Pixabay API call with `webformatURL` extraction and `"Photo by {user} on Pixabay"` credit
- [x] 3.3 Create `fetch_unsplash_image(query: str) -> tuple[str | None, str | None]` function
- [x] 3.4 Implement Unsplash API call with `urls.regular` extraction and `"Photo by {user.name} on Unsplash"` credit
- [x] 3.5 Create `fetch_pexels_image(query: str) -> tuple[str | None, str | None]` function
- [x] 3.6 Implement Pexels API call with `src.large` extraction and `"Photo by {photographer} on Pexels"` credit

## 4. Provider Fallback Chain

- [x] 4.1 Create provider registry mapping provider names to fetch functions
- [x] 4.2 Parse `ROYALTY_IMAGE_PROVIDERS` into ordered list at startup
- [x] 4.3 Implement `get_enabled_providers()` that filters by configured API keys
- [x] 4.4 Modify `fetch_royalty_free_image()` to iterate provider chain with fallback

## 5. Integration

- [x] 5.1 Wire refined query extraction into `fetch_royalty_free_image()` call
- [x] 5.2 Preserve MCP endpoint as highest priority (existing behavior)
- [x] 5.3 Preserve Wikimedia and Picsum as fallback providers in chain
- [x] 5.4 Add error logging for each provider failure with provider name

## 6. Documentation

- [x] 6.1 Update README environment variables table with new provider keys
- [x] 6.2 Add provider configuration section to README explaining priority chain
- [x] 6.3 Document attribution requirements for each provider

## 7. Verification

- [x] 7.1 Test Pixabay provider with sample query (requires API key)
- [x] 7.2 Test Unsplash provider with sample query (requires API key)
- [x] 7.3 Test Pexels provider with sample query (requires API key)
- [x] 7.4 Test fallback chain when primary provider fails
- [x] 7.5 Test fallback to Picsum when no API keys configured
- [x] 7.6 Verify attribution format matches provider requirements
