feat(ai): add OpenAI-compatible provider support by monotykamary · Pull Request #5 · SuperCmdLabs/SuperCmd · GitHub
Skip to content

feat(ai): add OpenAI-compatible provider support#5

Merged
shobhit99 merged 7 commits into
SuperCmdLabs:mainfrom
monotykamary:feat/openai-compatible-provider
Feb 18, 2026
Merged

feat(ai): add OpenAI-compatible provider support#5
shobhit99 merged 7 commits into
SuperCmdLabs:mainfrom
monotykamary:feat/openai-compatible-provider

Conversation

@monotykamary

@monotykamary monotykamary commented Feb 18, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR adds support for custom OpenAI-compatible API providers, allowing users to connect to services like OpenRouter, Together AI, or self-hosted endpoints that implement the OpenAI API format.

image

Changes

Core Implementation

  • AI Settings: Added "openai-compatible" provider type with three new configuration fields:
    • openaiCompatibleBaseUrl: The API endpoint URL (e.g., https://api.openrouter.ai/v1)
    • openaiCompatibleApiKey: Authentication key for the provider
    • openaiCompatibleModel: Custom model identifier (e.g., anthropic/claude-3.5-sonnet)

Provider Logic

  • Implemented streamOpenAICompatible() streaming function that sends standard OpenAI-formatted requests to any compatible endpoint
  • Updated model routing to handle openai-compatible- prefixed model IDs
  • Added availability checks requiring both base URL and API key

UI Updates

  • Added new "Custom (OpenAI-compatible)" provider option in the AI settings
  • Added configuration form with base URL, API key (with visibility toggle), and model name inputs
  • Updated provider selection grid to accommodate the new option
  • Added helpful placeholder text and guidance for popular providers

Usage Examples

Users can now configure providers like:

  • OpenRouter: https://api.openrouter.ai/v1 with model anthropic/claude-3.5-sonnet
  • Together AI: https://api.together.xyz/v1 with model meta-llama/llama-3.1-70b
  • Self-hosted: Local endpoints running OpenAI-compatible APIs

Testing

  • Verified model routing correctly resolves openai-compatible model IDs
  • Verified streaming implementation properly handles SSE responses
  • Verified UI state management for the new provider type

Closes #2

Add support for custom OpenAI-compatible API providers like OpenRouter,
Together AI, and self-hosted endpoints.

Changes:
- Add 'openai-compatible' provider type to AISettings
- Add openaiCompatibleBaseUrl, openaiCompatibleApiKey, and openaiCompatibleModel fields
- Implement streamOpenAICompatible() for streaming completions
- Add UI section in AITab for configuring custom provider settings
- Update model routing and availability checks

Closes #2
Change provider selection grid from 4 columns to 2 columns to give
cards more horizontal space and prevent text from being squashed,
especially for the longer 'Custom (OpenAI-compatible)' label.
Fix URL construction to properly handle providers like Fireworks AI that
include /v1 in the base URL. Previously we always appended /v1/chat/completions
to the base URL, which caused double /v1 paths.

Now we check if the base URL already ends with /v1 and only append
/chat/completions in that case, otherwise we append /v1/chat/completions
for backwards compatibility.
@monotykamary monotykamary marked this pull request as draft February 18, 2026 08:48
Add custom model option for openai-compatible provider in the Default Model
dropdown. When the Model Name field is updated, it now automatically updates
the defaultModel with the proper openai-compatible- prefix.

This ensures the model ID is properly resolved when using the chat feature
with custom OpenAI-compatible providers like Fireworks AI.
…compatible

Fix empty string handling in resolveModel defaults - previously an empty
string would fall through to the hardcoded default 'gpt-4o' instead of
checking the user's configured model.

Add debug logging to help diagnose routing issues with the openai-compatible
provider. This will log the resolved provider, model ID, and config values
to the console for troubleshooting.
The prefix matching was matching 'openai-' before 'openai-compatible-',
causing 'openai-compatible-accounts/fireworks/...' to be incorrectly parsed
as an OpenAI model with ID 'compatible-accounts/fireworks/...'.

Reorder prefixes to check longer ones first:
- 'openai-compatible-' before 'openai-'
- 'anthropic-' and 'ollama-' in between
Remove debug console.log that was added for troubleshooting the
openai-compatible provider routing issues.
@monotykamary monotykamary marked this pull request as ready for review February 18, 2026 09:01
@shobhit99

Copy link
Copy Markdown
Contributor

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.

feat: support openai compatible APIs

2 participants