Skip to content

feat: add URL backend for custom LLM endpoints#9640

Merged
Ali-Sab merged 2 commits intoKong:developfrom
Ali-Sab:feat/add-llm-url-option
Feb 9, 2026
Merged

feat: add URL backend for custom LLM endpoints#9640
Ali-Sab merged 2 commits intoKong:developfrom
Ali-Sab:feat/add-llm-url-option

Conversation

@Ali-Sab
Copy link
Contributor

@Ali-Sab Ali-Sab commented Feb 5, 2026

Feature: Custom URL Backend

Adds support for OpenAI-compatible LLM endpoints via custom URLs.

Backend

  • Added url and baseURL to the LLMConfig interface.
  • Updated config services to handle URL fields and filtering.
  • Refactored code to use the LLM_BACKENDS constant.
  • Added 15 new unit tests for backend operations.

Frontend

  • New URL Component: Handles configuration, HTTP/HTTPS validation, and model fetching.
  • State Management: Moved AI features to a unified aiFeatures object.
  • Navigation: Added URL options to the AI settings menu.

Consistency Updates
Standardized the UI across Claude, Gemini, OpenAI, and GGUF:

  • Added loading spinners and button disable logic.
  • Standardized error messages and helper text.
  • Linked documentation in the UI.

Files Changed

  • constants.ts (Added URL backend type)
  • llm-config-service.ts & .test.ts (Backend logic and tests)
  • ai-settings.tsx & url.tsx (Settings UI and new component)
  • claude.tsx, gemini.tsx, openai.tsx, gguf.tsx (UI polish)

@Ali-Sab Ali-Sab force-pushed the feat/add-llm-url-option branch 2 times, most recently from 786adcb to 2e974e2 Compare February 6, 2026 03:18

export const ACCEPTED_NODE_CA_FILE_EXTS = ['.pem', '.crt', '.cer', '.p12'];

export const LLM_BACKENDS = ['gguf', 'claude', 'openai', 'gemini'] as const;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/Kong/insomnia/blob/develop/packages/insomnia/src/plugins/types.ts#L3-L25 is used in a few places and is missing the new backend type, along with the url field. Right now, the generate commit diffs and mcp sampling both use this interface and would likely fail if the url backend were configured

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Let me update this, and some other fields in this file to show what the LLM URL option can support

try {
setIsLoadingModels(true);
setError(null);
const response = await fetch(`${realUrl}/models`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we be wrapping this in a timeout for this or some sort of option to prevent it from hanging if it's incorrect?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we be using new URL to get better path safety?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding both of these in the next revision, let me know your thoughts on them 🙏

@Ali-Sab Ali-Sab force-pushed the feat/add-llm-url-option branch 2 times, most recently from da322ea to f12fb62 Compare February 7, 2026 03:02
@Ali-Sab
Copy link
Contributor Author

Ali-Sab commented Feb 7, 2026

Additional changes since initial commit:

  • Added 'url' backend and url field to ModelConfig in types.ts so commit generation and MCP sampling work with the URL backend
  • Improved URL fetch robustness: 10s timeout via AbortController, safe path construction with new URL(), JSON parse guard, and user feedback when no models are found
  • Found issue where if MCP Server specifies a token count that is too low, than that parameter is passed on and can limit max tokens to a number that isn't enough for the LLM to reply, which results in failures that are difficult to debug. Fixed by enforcing min token count.

// Enforce minimum maxTokens to prevent unreasonably low limits from MCP servers
// that would result in truncated/incomplete responses and silent failures.
const MIN_MAX_TOKENS = 1000;
if (finalModelConfig.maxTokens !== undefined && finalModelConfig.maxTokens < MIN_MAX_TOKENS) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we instead be surfacing an error or enforcing this in the settings so this behaviour is more visible?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, yes. I'd rather not have some automatically enforced value and instead give the user the ability to specify a max token override.

I can try adding something of that sort, like a Max Token Override in the settings. We should ideally have this for all types of AI models, but it felt like this PR might get too big. Thoughts going forward?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we should add this minimum max token enforcement as part of a follow-up in that case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be okay with that, and we can try a better quality solution with it. I'll make a rev to remove this out for now

* Add support for configuring custom OpenAI-compatible LLM endpoints via URL.
* Includes new URL backend component, backend service updates, unit tests, and
* UI consistency improvements across all LLM configuration components.
@Ali-Sab Ali-Sab force-pushed the feat/add-llm-url-option branch from f12fb62 to 298b15d Compare February 9, 2026 19:51
@Ali-Sab Ali-Sab merged commit 9e29c40 into Kong:develop Feb 9, 2026
10 checks passed
govambam added a commit to govambam/insomnia that referenced this pull request Feb 10, 2026
* Add support for configuring custom OpenAI-compatible LLM endpoints via URL.
* Includes new URL backend component, backend service updates, unit tests, and
* UI consistency improvements across all LLM configuration components.
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.

3 participants