swift-realtime-openai  by m1guelpf

Swift SDK for OpenAI's Realtime API, enabling multimodal conversations

created 10 months ago
347 stars

Top 81.1% on sourcepulse

GitHubView on GitHub
Project Summary

This Swift SDK provides a modern, high-level interface for OpenAI's Realtime API, targeting Swift developers building applications that require multi-modal conversational AI. It simplifies the integration of features like automatic microphone recording, audio playback, and transparent API management, enabling rapid development of interactive AI experiences.

How It Works

The SDK offers two primary interaction layers: RealtimeAPI for direct, low-level API access via WebSockets or WebRTC, and Conversation for a managed, stateful experience. The Conversation class abstracts away the complexities of sending/receiving messages, managing conversation history, and optionally handling audio input/output, making it easier to build features like voice-enabled chatbots.

Quick Start & Requirements

  • Installation: Swift Package Manager (SPM). Add https://github.com/m1guelpf/swift-realtime-openai.git to your Xcode project or Package.swift.
  • Prerequisites: OpenAI API Key.
  • Demo: The README includes example code for building an iMessage-like app and a simple voice interaction app in under 60 lines of Swift.

Highlighted Details

  • High-level Conversation class manages state and audio I/O.
  • Supports direct API interaction via RealtimeAPI (WebSocket/WebRTC).
  • Optional automatic microphone recording and response playback.
  • Ability to interrupt model responses.
  • Customizable session parameters (e.g., system prompt, input transcription).

Maintenance & Community

The project is maintained by m1guelpf. No specific community channels or roadmap links are provided in the README.

Licensing & Compatibility

  • License: MIT License.
  • Compatibility: Permissive MIT license allows for commercial use and integration into closed-source projects.

Limitations & Caveats

WebRTC support is listed as a planned feature but not yet implemented. The README indicates that direct RealtimeAPI event sending bypasses some Conversation class logic, suggesting preference for the higher-level interface where possible.

Health Check
Last commit

2 weeks ago

Responsiveness

1+ week

Pull Requests (30d)
2
Issues (30d)
1
Star History
30 stars in the last 90 days

Explore Similar Projects

Feedback? Help us improve.