Skip to content

Add optional custom base URL for AI providers#4

Open
johncarbon88 wants to merge 4 commits into
seriaati:mainfrom
johncarbon88:custom-ai-provider-base-url
Open

Add optional custom base URL for AI providers#4
johncarbon88 wants to merge 4 commits into
seriaati:mainfrom
johncarbon88:custom-ai-provider-base-url

Conversation

@johncarbon88

Copy link
Copy Markdown
Contributor

Add optional custom base URL for AI providers

image

@johncarbon88 johncarbon88 force-pushed the custom-ai-provider-base-url branch from 7d7dd45 to 377e0d1 Compare May 20, 2026 03:42
@seriaati

Copy link
Copy Markdown
Owner

A couple of things to change:

  1. To avoid SSRF, validate that the base_url is not something suspicious, like an internal service.
  2. Add an env var flag for disabling this feature, I don't want to enable it on the hosted instance due to possible risks. You can however, use it freely on the self-hosted version.
  3. In _factory.py, there is now base_url=base_url or "https://openrouter.ai/api/v1" for OpenRouter. I don't think this is needed, because OpenRouter obviously is OpenAI-compatible and there is no need to set a base URL for OpenRouter. This can also confuse the user if they set both a custom base URL + select OpenRouter.
  4. base_url.strip() normalization is duplicated across different files. Would probably easier to just use a Pydantic schema validator and do it there.

@seriaati

Copy link
Copy Markdown
Owner
  1. The PR's migration down revision needs to be updated to the latest one.

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.

2 participants