Skip to content

feat(llm): add API format selector to custom provider for OpenAI compatibility#13

Open
h0ll0w-AkuZr0guY wants to merge 1 commit intoNevaMind-AI:mainfrom
h0ll0w-AkuZr0guY:feature/custom-openai-format
Open

feat(llm): add API format selector to custom provider for OpenAI compatibility#13
h0ll0w-AkuZr0guY wants to merge 1 commit intoNevaMind-AI:mainfrom
h0ll0w-AkuZr0guY:feature/custom-openai-format

Conversation

@h0ll0w-AkuZr0guY
Copy link
Contributor

Description

This PR addresses the issue where using an OpenAI-compatible endpoint (like free.v36.cm or local proxies) in the Custom provider results in a 404 error. The error occurs because the application previously defaulted all custom endpoints to Anthropic's /v1/messages format, whereas OpenAI-compatible APIs expect /v1/chat/completions.

Instead of using implicit URL pattern detection, I implemented a more reliable explicit approach: adding an API Format selector (Anthropic Standard vs. OpenAI Compatible) under the Custom provider settings. This routes requests through the newly implemented openai-adapter.ts when needed, ensuring perfect compatibility without breaking existing custom Anthropic endpoints.

Fixes #12

Key Changes

  • Settings UI: Added an API Format dropdown in GeneralSettings.tsx when the Custom provider is selected.
  • Config & Types: Updated shared.tsx, preload/index.d.ts, and settings.config.ts to include the customFormat state ('anthropic' | 'openai').
  • Client Factory: Modified createClient in utils.ts to return an OpenAI client instance if the user selects the openai format.
  • Agent Routing: Expanded the adapter condition in agent.service.ts (runAgentLoop and evaluate) to route custom + openai format requests through the runOpenAIAdapter.

Testing Instructions

  1. Navigate to Settings > General, select Custom Provider.

  2. Change the API Format to OpenAI Compatible.

  3. Input an OpenAI-compatible proxy URL (e.g., http://localhost:11434/v1) and API Key.

  4. Test a conversation to verify successful communication via /v1/chat/completions.

Screenshots

image

Checklist

  • Followed TypeScript best practices and added type annotations
  • Tested changes locally (npm run dev:memu)

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.

Could you please fix this or add a custom endpoint option?

1 participant