WritingTools
WritingTools copied to clipboard
OpenAI-compatible API support fails with custom Base URL.
TLDR: Added custom request handling for OpenAI API with base URL support.
Description
When configuring the OpenAI provider with a custom Base URL (e.g., for Groq or other compatible services), the application fails to successfully complete requests. This issue appears to stem from the AIProxy dependency, which may not correctly handle custom endpoints or the specific response formats returned by third-party providers.
Resolution
I have implemented a fix in OpenAIProvider.swift to improve compatibility:
- Detection: The provider now checks if a custom
baseURLis set (different from the default OpenAI URL). - Direct Fallback: When a custom URL is detected, the app bypasses
AIProxyand uses a directURLSessionimplementation to send the request. - Verification: This has been tested and verified to work correctly with Groq (
https://api.groq.com/openai/v1) using theopenai/gpt-oss-120bmodel.
This ensures that the application can support any standard OpenAI-compatible provider without being limited by the proxy service's constraints.