Skip to content

feat: add configurable OpenAI base URL for LiteLLM / OpenRouter / custom proxies - #36

Open
tonyfruzza wants to merge 5 commits into
clucraft:mainfrom
tonyfruzza:feature/litellm-openai-base-url
Open

feat: add configurable OpenAI base URL for LiteLLM / OpenRouter / custom proxies#36
tonyfruzza wants to merge 5 commits into
clucraft:mainfrom
tonyfruzza:feature/litellm-openai-base-url

Conversation

@tonyfruzza

Copy link
Copy Markdown

Summary

Adds an optional OpenAI Base URL field to the AI Extraction settings page. When set, the OpenAI SDK's baseURL is overridden so that any OpenAI-compatible endpoint can be used in place of api.openai.com.

This enables:

  • LiteLLM proxy — self-hosted gateway that routes to DeepSeek, Bedrock, Groq, etc.
  • OpenRouter — aggregator with access to hundreds of models
  • OpenWebUI — local Ollama proxy exposed as an OpenAI-compatible API
  • Any other OpenAI-compatible API without needing a new provider type

Changes

  • database/init.sql — migration: ALTER TABLE users ADD COLUMN openai_base_url VARCHAR(512)
  • backend/src/config/init-db.ts — migration added so fresh npm run db:init deployments also get the column
  • backend/src/models/index.tsAISettings interface and all DB queries include openai_base_url
  • backend/src/routes/settings.ts — GET/PUT /api/settings/ai include openai_base_url
  • backend/src/services/ai-extractor.ts — all four OpenAI call sites (extract, verify, verifyStockStatus, arbitrate) accept and forward baseURL
  • frontend/src/pages/Settings.tsx — new optional text input under the OpenAI provider section
  • frontend/src/api/client.tsopenai_base_url added to AI settings type

Backward compatibility

The openai_base_url field defaults to NULL. When null, behaviour is identical to before — the OpenAI SDK uses its default api.openai.com endpoint. Existing deployments are not affected.

Closes

Closes #21 (custom API URL for OpenAI-compatible proxies like OpenWebUI)
Closes #23 (OpenRouter support — set base URL to https://openrouter.ai/api/v1, use any model name)

Testing

Tested against a self-hosted LiteLLM instance routing to DeepSeek (deepseek-v4-flash) — extraction, verification, and arbitration all function correctly.

1. scraper.ts: Update URL match regex to accept a.co short links
   in addition to full amazon.com URLs

2. products.ts: Use voting-based scraper in confirmed-price flow
   for richer price candidate data

3. Add k8s manifests for deploy via GH Actions
Merges fix/aco-url-support into main
The Sec-* and Cache-Control headers in the axios request config trigger
Amazon's bot detection, returning a 5KB blocking page instead of the
full product page. This breaks ALL Amazon scraping, not just a.co links.

Removed headers: Cache-Control, Pragma, Sec-Ch-Ua, Sec-Ch-Ua-Mobile,
Sec-Ch-Ua-Platform, Sec-Fetch-Dest, Sec-Fetch-Mode, Sec-Fetch-Site,
Sec-Fetch-User, Upgrade-Insecure-Requests
fix: remove bot-triggering headers from Amazon HTTP requests
@stevene1919

Copy link
Copy Markdown

@tonyfruzza hey you might like to contribute to our active fork of this
https://github.com/mikeknight85/PriceStalker

cheers
steven

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenRouter OpenAI AI Provider

2 participants