MacPaw/OpenAI
62.1
Adequate · 30 September 2026
36.7k
lines of production code
Swift
primary language
2
measurements over time
What this system is
This system is a Swift SDK for interacting with OpenAI and Gemini APIs, providing both synchronous and modern async/await and Combine interfaces. It supports a wide range of capabilities including chat, audio, image generation, and the newer Responses and Assistants APIs, with robust handling for streaming and tool use. The library includes a demo application to showcase these features and an automated pipeline for generating Swift code from OpenAPI specifications.
How it got here
2023 — SDK modernization and API expansion
15 changes.
The project underwent a major SDK overhaul to support modern Swift concurrency patterns and new OpenAI API capabilities, including the Assistants and Responses APIs. This period focused on refactoring the internal request architecture, expanding model and error handling support, and introducing comprehensive test coverage for streaming and cancellation. A new demo application was also added to showcase multi-provider integration and the updated SDK features.
2025–2026 — Responses API and streaming infrastructure
12 changes.
This period focused on implementing the new OpenAI Responses API, including comprehensive streaming support with SSE parsing and memory safety protections. The codebase was updated to align with the latest OpenAPI specification, introducing new schema types for function calling, MCP tools, and web search. Additionally, a robust automation pipeline was established to handle OpenAPI spec preparation and Swift code generation.
Features
Add Demo app project with file sharing and API key entry
The Demo app project is introduced, providing a starter UI for testing the SDK. It includes a project configuration that enables file sharing (UIFileSharingEnabled) and integrates the DemoChat framework. The app features a ContentView and an APIKeyModalView, allowing users to input their API credentials to interact with the backend services.
Demo/Demo.xcodeproj · high confidence
Add OpenAI and Gemini API error types with flexible message decoding
The library now includes dedicated error types for OpenAI and Gemini API responses. For OpenAI, the new \APIError\ struct handles decoding errors where the message field can be either a single string or an array of strings, joining array messages with newlines for a consistent user-facing description. A new \OpenAIError\ enum covers local issues like empty data and HTTP status errors. Additionally, \GeminiAPIError\ and \GeminiAPIErrorResponse\ structs are introduced to handle errors specific to the Gemini API, providing structured access to error codes, messages, and statuses.
Sources/OpenAI/Public/Errors · high confidence
Added debug descriptions for generated Response API schemas
The library now includes human-readable debug descriptions for several generated schema types related to the OpenAI Responses API, including \ResponseCreatedEvent\, \Response\, \ModelResponseProperties\, \ResponseTextDeltaEvent\, \ResponseOutputTextAnnotationAddedEvent\, and \ResponseTextDoneEvent\. This improves the readability of these objects when printed or logged during development.
Sources/OpenAI/Private/Extensions for generated code · high confidence
Added script to remove required properties from OpenAPI schemas
A new Python script, \Scripts/remove\_required\_properties.py\, has been added to handle OpenAPI schema generation workarounds. This tool allows users to strictly remove specific properties from the \required\ lists of component schemas in an OpenAPI document. It enforces strict matching to ensure transformations are applied to the correct locations and can optionally generate a unified diff of the changes.
python · high confidence
Automated OpenAPI spec preparation and code generation pipeline
Added a new automation pipeline in the Scripts directory to prepare upstream OpenAPI specifications for the Swift OpenAPI generator and generate Swift code. The pipeline includes a main orchestrator (prepare\_openapi.py) that applies several workarounds to fix generator incompatibilities: converting OpenAPI 3.0 boolean exclusiveMinimum syntax to 3.1, replacing unsupported $recursiveRef with standard $ref, fixing rounded Int64 bounds that cause parsing errors, and removing unsupported top-level webhooks. Additionally, extract\_components.py is provided to extract the generated Components enum from Types.swift and splice it into Components.swift, stripping redundant typealiases that shadow Swift built-in types to prevent build errors.
Scripts · high confidence
Demo app adds multi-provider support, MCP tool integration, and expanded API demos
The DemoChat application has been significantly expanded to demonstrate a wider range of OpenAI capabilities and integrations. Users can now switch between OpenAI, Gemini, and custom API providers via a new configuration system that validates endpoint URLs. The demo includes a dedicated interface for connecting to the GitHub MCP server, allowing users to discover, enable, and disable specific tools for function calling. New screens and stores demonstrate the Assistants API (with code interpreter, file search, and function definitions), the Responses API (including streaming, web search, and function calling), image generation and editing, text-to-speech, and content moderation. The chat interface now supports streaming responses, image attachments with automatic resizing, and conversation history management.
Demo/DemoChat · high confidence
Expanded model support for Assistants, Audio, and Chat APIs
This update introduces new public model types to support recent OpenAI API capabilities. For the Assistants API, it adds \Annotation\ (for web search URL citations), \AssistantResult\, \AssistantsQuery\, \AssistantsResult\, and \AssistantsTool\ (supporting code interpreter, file search, and function tools). Audio capabilities are expanded with \AudioSpeechQuery\ and \AudioSpeechResult\ for text-to-speech, \AudioTranscriptionQuery\ and \AudioTranscriptionResult\ for speech-to-text, and \AudioTranslationQuery\ and \AudioTranslationResult\ for translation. Chat models are updated with \ChatQuery\ and \ChatResult\ to support new features like reasoning effort, structured outputs, and audio modalities, alongside \ChatStreamResult\ for streaming responses.
Sources/OpenAI/Public/Models · high confidence
Introduce Demo app with provider configuration and multi-feature UI
The Demo app now includes a configuration modal (APIKeyModalView) that lets users select an API provider, set a custom base URL, and enter credentials, with validation for the endpoint. The main interface (ContentView) provides tabs for Chat, Responses, Transcription, Image generation, GitHub MCP tools, and Misc examples, wired to the OpenAI SDK client via APIProvidedView.
Demo/App · high confidence
Introduce public JSON Schema (2020-12) and JSON Document types
The library now exposes a public API for constructing and decoding JSON Schema documents compliant with the 2020-12 specification. This includes the \JSONSchema\ enum for defining schema structures (booleans or objects), the \JSONSchemaField\ struct with static helpers for schema keywords (such as \type\, \enum\, \allOf\, \anyOf\, and \$defs\), and the \AnyJSONDocument\ type for handling arbitrary JSON values. These types conform to \Codable\ and \Hashable\, enabling users to programmatically build and serialize JSON schemas for use with the OpenAI API.
Sources/OpenAI/Public/JSONSchema · high confidence
Introduces the OpenAI Responses API model types
Adds the public data models for the new Responses API, including \CreateModelResponseQuery\ for initiating requests (supporting features like structured outputs, verbosity, prompt caching, and context management), \ResponseObject\ for representing the response payload, and query/result types for retrieving, deleting, and handling streaming events. This enables users to interact with the Responses API surface directly.
Sources/OpenAI/Public/Models/Responses API · high confidence
Major SDK overhaul introducing async/Combine APIs, new endpoints, and configuration options
The OpenAI SDK has been significantly refactored to support modern concurrency patterns and new API capabilities. Users can now interact with the SDK using Swift's native async/await and Apple's Combine frameworks, as evidenced by the new \OpenAI+OpenAIAsync.swift\ and \OpenAI+OpenAICombine.swift\ files exposing methods for images, chats, audio, and assistants. The library now supports the new Responses API (create, retrieve, cancel) and the Assistants API (threads, runs, tool outputs). Configuration has been expanded via a new \Configuration\ struct, allowing users to set custom hosts, base paths, timeouts, and custom headers. Legacy endpoints like Completions and Edits have been removed in favor of newer APIs like Chat and Assistants.
Sources/OpenAI · high confidence
New Models API and Model Specification system
The library now supports querying the OpenAI Models API to retrieve available models and their metadata. This change introduces new public types (\ModelQuery\, \ModelResult\, \ModelsResult\) for API interactions and a new \ModelSpec\ system that defines model capabilities, supported endpoints (Chat Completions, Responses), tools (e.g., MCP), and reasoning effort levels. The \Models.swift\ file has been updated with a comprehensive list of supported models, including GPT-6, GPT-5, GPT-4.1, and various o-series reasoning models, along with deprecation notices for older models like o1-mini and gpt-4.5-preview.
Sources/OpenAI/Public/Models/Models · high confidence
New public protocols for JSON Schema conversion
Added three new public types in the JSONSchemaConvertible module to support structured outputs: the \JSONSchemaConvertible\ protocol (requiring a static \example\ property), the \JSONSchemaEnumConvertible\ protocol for enums (requiring \caseNames\), and the \JSONSchemaConvertationError\ enum to report specific conversion failures such as unsupported types or missing enum conformance.
Sources/OpenAI/Public/JSONSchemaConvertible · high confidence
New public protocols for async, Combine, and Responses API support
The library introduces a set of new public protocols to modernize the API surface and support newer OpenAI capabilities. \OpenAIAsync\ and \OpenAICombine\ provide native Swift concurrency (\async/await\) and reactive (\Combine\) interfaces for existing endpoints like Chat, Images, Audio, and Assistants. A new \ResponsesEndpointProtocol\ (with \Async\ and \Combine\ variants) exposes the Responses API, including create, retrieve, streaming, and cancel operations. Additionally, \CancellableRequest\ allows users to cancel in-flight requests, and \OpenAIMiddleware\ enables intercepting and modifying HTTP requests, streaming data, and responses.
Sources/OpenAI/Public/Protocols · high confidence
New streaming session infrastructure with SSE parsing and error handling
This change introduces a new internal streaming architecture in the \Sources/OpenAI/Private/Streaming\ directory, replacing or supplementing previous streaming implementations. It adds a robust \ServerSentEventsStreamParser\ that strictly follows the HTML5 SSE specification, including handling of UTF-8 BOMs, CRLF/LF line endings, and event buffering. The new system includes specific interpreters for different stream types: \ModelResponseEventsStreamInterpreter\ for the new Responses API (handling events like \response.output\_text.delta\, \response.mcp\_call\, and \response.shell\_call\), \AudioSpeechStreamInterpreter\ for audio streaming, and a generic \ServerSentEventsStreamInterpreter\ for other codable results. A key behavioral improvement is the introduction of bounded memory growth protection: non-2xx HTTP responses are now captured and buffered up to 256 KB before being decoded and surfaced as errors, preventing malicious servers from causing unbounded memory usage. The architecture also supports middleware interception of streaming data and proper session invalidation/cancellation.
Sources/OpenAI/Private/Streaming · high confidence
Removals
Removal of legacy Model enum
The public \Model\ enum, which previously exposed specific legacy OpenAI models (such as \text-davinci-003\ and \text-embedding-ada-002\), has been removed from the public API. Users relying on this specific enumeration for model selection will need to update their code, likely switching to the newer Chat API model identifiers or string-based model names introduced in recent updates.
Sources/OpenAI/Public · high confidence
Behavioural changes
Introduce ParsingOptions for configurable JSON decoding behavior
The library now exposes a public \ParsingOptions\ struct that allows users to control how missing data is handled during JSON decoding. Specifically, the new \fillRequiredFieldIfKeyNotFound\ and \fillRequiredFieldIfValueNotFound\ options enable a 'relaxed' parsing mode where required fields are populated with default values even if the key or value is absent in the response. This change also includes a minor file restructuring, moving the utilities code into a dedicated \Utilities\ subdirectory.
Sources/OpenAI/Public/Utilities · high confidence
Refactored HTTP client architecture with dedicated implementations for async, Combine, and streaming
The internal networking layer has been restructured into four distinct client implementations to better support different concurrency models. AsyncClient handles modern async/await requests with platform-specific fallbacks for older iOS/macOS versions, while Client provides the traditional completion-handler-based API. CombineClient exposes requests as Publishers for reactive workflows, and StreamingClient manages Server-Sent Events (SSE) and audio streaming sessions. All clients now consistently apply middleware interception to requests before execution, ensuring uniform request processing across all concurrency paradigms.
Sources/OpenAI/Private/Client · high confidence
Refactored request handling and added Assistants v2 support
The library has refactored its internal request architecture to support the new Assistants API (v2) and improve modularity. A new \AssistantsRequest\ class now handles API calls with the \OpenAI-Beta: assistants=v2\ header, while \JSONRequest\ and \MultipartFormDataRequest\ provide a unified, extensible way to build HTTP requests. This change also introduces a \URLRequestBuildable\ protocol, replacing the legacy \Request\ class, and adds support for custom headers, organization identifiers, and timeouts directly in the request building process.
Sources/OpenAI/Private · high confidence
Regenerated API schemas from updated OpenAPI specification
The generated API schema types in \Components.swift\ have been refreshed to align with the latest OpenAI OpenAPI specification. This update introduces new model support (including gpt-5.1 variants), adds features such as web search options and minimal reasoning effort, and refines existing structures like making \WebSearchActionSearch.query\ and \ResponseFunctionCallArgumentsDoneEvent.name\ optional to match the current API contract.
Sources/OpenAI/Public/Schemas/Generated · high confidence
Support for web search, structured output schemas, and service tier prioritization
The SDK now supports configuring web search via the new \ChatQuery.WebSearchOptions\ type, allowing users to specify user location and context size for search-enhanced completions. Structured outputs have been unified through a new \JSONSchemaDefinition\ enum that replaces the previous \AnyJSONSchema\ approach, offering cases for static JSON schemas, derived types, and dynamic encodable objects. Additionally, request prioritization is now possible via the \ServiceTier\ enum, which includes \auto\, \default\, \flex\, \on\_demand\, and \priority\ options to control latency and availability.
Sources/OpenAI/Public/Models/Types · high confidence
Updated ResponseStreamEvent and OutputItem facades to match latest OpenAPI spec
The public schema facades for \ResponseStreamEvent\ and \OutputItem\ have been regenerated and updated to align with the latest OpenAI API specification. This update introduces support for new streaming event types, including shell-call events (\ShellCallEvent\), MCP tool call events (\MCPCallEvent\, \MCPCallArgumentsEvent\), and web search options. It also adds new output item variants such as \localShellCall\, \functionShellCall\, \applyPatchToolCall\, \mcpToolCall\, and \customToolCall\. The \ResponseStreamEvent\ decoding logic has been rewritten to dispatch on the \type\ field first, ensuring correct handling of these new event structures and fixing previous issues with missing fields like \name\ in \ResponseFunctionCallArgumentsDoneEvent\.
Sources/OpenAI/Public/Schemas/Facade · high confidence
Updated Responses API schemas for function calling, MCP, and input items
The public schema layer for the Responses API has been updated to align with the latest OpenAPI specification and address upstream documentation bugs. Function calling is now supported via a new \FunctionTool\ schema and a unified \Tool\ enum that uses a type discriminator for decoding. Support for Model Context Protocol (MCP) tools is added through new \ResponseMCPCallArgumentsDeltaEvent\ and \ResponseMCPCallArgumentsDoneEvent\ types, which correct namespace and delta-type mismatches in the upstream spec. Input handling is expanded with new \EasyInputMessage\, \InputContent\, \InputImage\, and \InputItem\ schemas, enabling text, image, and file inputs as well as context compaction. Additionally, streaming events now include the \name\ field in \ResponseFunctionCallArgumentsDoneEvent\ and optional \sequenceNumber\ in item events to ensure compatibility with the live API.
Sources/OpenAI/Public/Schemas/Edited · high confidence
Test coverage
Added mock data generators and test utilities for OpenAI API types; Expanded test coverage for OpenAI client APIs and streaming; Expanded test mock infrastructure for streaming, cancellation, and middleware interception.
Dependencies
Updated Swift tools version, added new platforms, and upgraded dependencies
The main OpenAI package now requires Swift 5.10.0 and supports macOS 10.15, iOS 13, tvOS 13, watchOS 6, and visionOS 1. It has added a dependency on swift-openapi-runtime (version 1.8.2) and its corresponding test target. The Demo app has been updated to use ExyteChat 3.3.3, the Model Context Protocol Swift SDK 0.9.0, and AnchoredPopup 1.2.2, with resolved package pins reflecting these versions.
(dependencies) · high confidence
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
Score
- CAI 72 → 62 (-9.9)
- Rubric changed (rubric-2026.09.11 → rubric-2026.09.18) — scores are not directly comparable.
Lenses
- Code Health 92 → 92 (-0.4)
- Architecture 100 → 91 (-9.4)
- Maturity 62 → 46 (-16.0)
- Readiness 88 → 80 (-8.3)
- Security 68 → 68 (+0.0)
Resolved (12)
- Documentation: no installation or build instructions (README.md)
- Documentation: no usage examples (README.md)
- Duplicated block (12 lines × 2) (Sources/OpenAI/Public/Schemas/Generated/Components.swift)
- Duplicated block (13 lines × 2) (Sources/OpenAI/Public/Schemas/Generated/Components.swift)
- Duplicated block (9 lines × 2) (Sources/OpenAI/Public/Schemas/Edited/InputItem.swift)
- Duplicated block (9 lines × 2) (Sources/OpenAI/Public/Schemas/Edited/ResponseOutputItemAddedEvent.swift)
- Hotspot: Sources/OpenAI/Public/Schemas/Generated/Components.swift (Sources/OpenAI/Public/Schemas/Generated/Components.swift)
- Members sharing a duplicated core (27 members, 50+ identical tokens) (Sources/OpenAI/Public/Schemas/Generated/Components.swift)
- Members sharing a duplicated core (4 members, 50+ identical tokens) (Sources/OpenAI/Public/Schemas/Generated/Components.swift)
- Members sharing a duplicated core (6 members, 50+ identical tokens) (Sources/OpenAI/Public/Models/ChatQuery.swift)
- Members sharing a duplicated core (6 members, 50+ identical tokens) (Sources/OpenAI/Public/Schemas/Generated/Components.swift)
- Off-boarding risk: anonymized user #1
New (82)
- Duplicated block (10 lines × 3) (Sources/OpenAI/Public/Schemas/Generated/Components.swift)
- Duplicated block (11 lines × 2) (Sources/OpenAI/Public/Schemas/Edited/ResponseOutputItemAddedEvent.swift)
- Duplicated block (12 lines × 2) (Sources/OpenAI/Public/Schemas/Edited/InputItem.swift)
- Duplicated block (12 lines × 2) (Sources/OpenAI/Public/Schemas/Edited/ResponseFunctionCallArgumentsDoneEvent.swift)
- Duplicated block (13 lines × 2) (Sources/OpenAI/Public/Schemas/Generated/Components.swift)
- Duplicated block (13 lines × 2) (Sources/OpenAI/Public/Schemas/Generated/Components.swift)
- Duplicated block (18 lines × 2) (Sources/OpenAI/Public/Schemas/Generated/Components.swift)
- Duplicated block (5 lines × 2) (Scripts/prepare_openapi.py)
- Duplicated block (6 lines × 3) (Scripts/fix_boolean_exclusive_minimum.py)
- Duplicated block (7 lines × 2) (Demo/App/APIKeyModalView.swift)
- Duplicated block (7 lines × 2) (Sources/OpenAI/Public/Schemas/Generated/Components.swift)
- Duplicated block (7 lines × 2) (Sources/OpenAI/Public/Schemas/Generated/Components.swift)
- Hotspot: Demo/DemoChat/Sources/Models/APIProvider.swift (Demo/DemoChat/Sources/Models/APIProvider.swift)
- Hotspot: Demo/DemoChat/Sources/ResponsesStore.swift (Demo/DemoChat/Sources/ResponsesStore.swift)
- Hotspot: Sources/OpenAI/Public/Schemas/Facade/OutputItem.swift (Sources/OpenAI/Public/Schemas/Facade/OutputItem.swift)
- Hotspot: Sources/OpenAI/Public/Schemas/Facade/ResponseStreamEvent.swift (Sources/OpenAI/Public/Schemas/Facade/ResponseStreamEvent.swift)
- Inconsistent method naming pattern for image operations. images is generic, while imageEdits and imageVariations are specific. If images is intended to be the general endpoint, it should likely accept a variant parameter, or the specific methods should be named createImage, editImage, createImageVariation to be more explicit about the action. Currently, images implies a list/retrieval operation, while imageEdits implies a mutation. This is a semantic inconsistency in naming conventions (Noun vs Verb-Noun).
- Inconsistent naming for related operations. audioTranscriptions and audioTranscriptionsVerbose perform the same core operation (transcription) but return different result types. While the verb 'Verbose' distinguishes the output, it is inconsistent with how other APIs might handle this (e.g., via a parameter or distinct method names like transcribe vs transcribeVerbose). However, given the distinct return types, this is a minor inconsistency. A more significant issue is the lack of a unified transcribe method that accepts a format parameter, but the current split is acceptable if documented well. Self-correction: This is actually consistent enough as they return distinct types. I will skip this.
- Low coverage: Sources/OpenAI/OpenAI.swift (Sources/OpenAI/OpenAI.swift)
- Low coverage: Sources/OpenAI/Private/CancellablesFactory.swift (Sources/OpenAI/Private/CancellablesFactory.swift)
- …and 62 more
Changes since last survey
- 53 commits — 33 feature/other, 20 fixes
By area
- (root) — 16 commits
- Sources/OpenAI — 15 commits
- (repo) — 10 commits
- Demo/DemoChat — 7 commits
- Tests/OpenAITests — 4 commits
- .github/workflows — 1 commit
Notable commits
- fix: Bug: Apply demo provider settings atomically and validate endpoints
- fix: Bug: Validate Demo provider endpoint URLs
- fix: Merge pull request #454 from taekop/bug/427-response-stream-event-encode
- fix: bug(responses): add matching encode(to:) to ResponseStreamEvent and OutputItem
- fix: bug(responses): preserve sequence_number on output item events
- fix: fix: add missing Tool/stream-event cases found in OpenAPI sync review
- fix: fix: avoid mutating a captured local var in a @Sendable closure
- fix: fix: cap buffered streaming error body to bound memory growth
- fix: fix: decode web_search_call output items without an action
- fix: fix: don't crash decoding an empty Gemini error array
- fix: fix: download openapi.yaml atomically to avoid a truncated spec
- fix: fix: fall back to lastOpenAIResponseId for MCP approval on non-streaming responses
- fix: fix: handle reasoning and MCP output items in non-streaming Responses path
- fix: fix: import FoundationNetworking for HTTPURLResponse on Linux in tests
- fix: fix: keep generate as the Makefile's default goal
- fix: fix: match item_reference discriminator and align InputItem facade
- fix: fix: migrate Demo to ExyteChat 3.x and unblock the build on Xcode 27
- fix: fix: surface the real error body for failed streaming requests
- fix: fix: switch Chat back to upstream now that the Xcode 27 fix is released
- fix: fix: use a unique temp file when downloading the OpenAPI spec
- …and 33 more
Architecture
- Unchanged — 0 containers · 1 contexts · 0 edges
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
MacPaw/OpenAI was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 30 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit c155b5245243f4984791bbe2db80be509b00854a — the exact code this score is about.
- Scored under rubric-2026.09.18 — the same rubric and the same method as every other entry in this index.
- Measured by watchdog.canine.dev using codehealth-analyzer preprod-cb25ca4feafa.