Skip to content

Add OpenAI-compatible API provider support - #213

Open
f33rx wants to merge 21 commits into
gluonfield:mainfrom
f33rx:claude/add-openai-gateway-support-CwgcS
Open

Add OpenAI-compatible API provider support#213
f33rx wants to merge 21 commits into
gluonfield:mainfrom
f33rx:claude/add-openai-gateway-support-CwgcS

Conversation

@f33rx

@f33rx f33rx commented Jan 26, 2026

Copy link
Copy Markdown

Summary

This PR adds support for OpenAI-compatible APIs (such as LiteLLM, OpenRouter, and Azure OpenAI) alongside the existing Ollama integration. Users can now switch between providers in settings and use any OpenAI-compatible endpoint.

Key Changes

  • ModelProvider enum enhancement: Added openAI case with String conformance, CaseIterable, and a displayName property for UI presentation
  • New OpenAIService: Comprehensive service implementation supporting:
    • Model listing from OpenAI-compatible endpoints
    • Streaming chat completions with proper SSE parsing
    • Image support detection based on model name patterns
    • Bearer token authentication
    • Configurable base URL and API key via UserDefaults
  • Settings UI updates:
    • Added provider selector (segmented picker between Ollama and OpenAI Compatible)
    • Conditional UI sections showing relevant configuration fields for each provider
    • OpenAI section includes URI and API key fields with helpful description text
  • Provider-aware message handling:
    • ConversationStore now routes requests to appropriate service based on selected provider
    • Added convertToOpenAIMessages() helper to transform message format
    • Separate response handlers for OpenAI streaming responses
  • Store updates:
    • AppStore.reachable() checks appropriate service based on provider
    • LanguageModelStore.loadModels() fetches from selected provider
    • PanelCompletionsVM supports both providers for macOS panel completions

Implementation Details

  • OpenAI message content supports both string and array formats (for vision/image support)
  • Streaming responses properly handle SSE format with [DONE] sentinel
  • Image support is auto-detected for models containing keywords like "vision", "gpt-4o", "claude-3", "llava"
  • Provider selection is persisted in UserDefaults and defaults to Ollama for backward compatibility
  • Both services implement consistent interfaces for model fetching and chat operations

@f33rx
f33rx force-pushed the claude/add-openai-gateway-support-CwgcS branch from 5ffb38d to 3dfb7dc Compare January 29, 2026 03:11
f33rx and others added 9 commits January 28, 2026 22:12
Add support for connecting to OpenAI-compatible API gateways like LiteLLM,
OpenRouter, Azure OpenAI, and other providers that implement the OpenAI API.

Changes:
- Add OpenAIService with streaming chat completions and model listing
- Add provider selection toggle in Settings (Ollama vs OpenAI Compatible)
- Update ModelProvider enum with openAI case
- Update LanguageModelStore to fetch models from selected provider
- Update ConversationStore to route chat requests to correct API
- Update PanelCompletionsVM for OpenAI support
- Update AppStore reachability checks for both providers
Adds CI/CD pipeline that:
- Builds the macOS app on macOS 14 with Xcode 16.1
- Creates an unsigned .app for testing
- Packages into a DMG installer
- Uploads artifacts for download
- Creates draft releases when tags are pushed

Triggers on pushes to main, claude/* branches, tags, and PRs.
The file was created but not added to the Xcode project file,
causing build failures in CI. This adds the necessary entries
to project.pbxproj.
- Remove archive/export steps that require code signing
- Build directly to DerivedData and copy the .app
- Remove error-swallowing || true to see actual failures
- Use explicit paths for build products
The OpenAIService.chat() expects Double? but CompletionInstructionSD.modelTemperature
is Float?. Convert Float to Double to fix build error.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@f33rx
f33rx force-pushed the claude/add-openai-gateway-support-CwgcS branch from 3dfb7dc to fb752bd Compare January 29, 2026 03:12
f33rx and others added 12 commits January 28, 2026 22:34
Document how to install unsigned builds on macOS (Gatekeeper bypass
via xattr -cr and System Settings) and iOS (AltStore, Sideloadly,
Apple Configurator 2). Includes troubleshooting for common issues.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add INSTALL.md with sideloading docs for macOS (Gatekeeper bypass)
  and iOS (AltStore, Sideloadly, Apple Configurator 2)
- Add GitHub Actions workflow for iOS builds (simulator and device)
- Produces downloadable .ipa artifacts for sideloading

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Merged polecat branches:
- polecat/jasper/hq-cv-5sjku
- polecat/quartz/hq-hku

Resolved INSTALL.md conflict by combining best content from both.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
iPhone 15 simulator is not available by default on macos-14 runners
with Xcode 16.1. Xcode 16.1 ships with iOS 18.1 runtimes that include
iPhone 16 series simulators.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add GitHub Actions workflow that builds the project for iPadOS using
iPad Pro 13-inch (M4) simulator on macOS 14 runner.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add NavigationSplitView for iPad (regular width) with persistent sidebar
- Keep drawer-style SideBarStack for iPhone (compact width)
- Update EmptyConversaitonView to use 4 columns on iPad vs 2 on iPhone
- Add toolbar with model selector and new conversation button for iPad
- Detect horizontal size class to adapt layout dynamically

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Use NavigationSplitView on iPad (regular horizontal size class) for proper
iPad multitasking support including Split View and Slide Over modes.
iPhone continues to use the SideBarStack slide-out drawer.

Changes:
- Chat.swift: Detect horizontal size class and use NavigationSplitView
  on iPad for proper sidebar behavior in multitasking scenarios
- ChatView_iOS.swift: Hide hamburger menu and new conversation buttons
  on iPad since NavigationSplitView provides built-in sidebar controls

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Ignore local tooling directories:
- .runtime/ - runtime artifacts
- .claude/ - Claude Code session data
- .beads/ - beads database
- .logs/ - local logs

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- en-ilk: Add iPadOS build target to CI workflow
- en-tg8: Fix UI scaling for iPad screen sizes
- en-2lq: Add iPad multitasking support (Split View, Slide Over)
- en-vv2: Fix failing iOS CI build

Resolved Chat.swift conflict by combining both iPad improvements:
- #if os(iOS) guards for iPad-specific properties
- NavigationSplitView for regular size class (iPad)
- .navigationSplitViewStyle(.balanced) for proper split view
- columnVisibility control for menu tap behavior

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.

1 participant