# macpaw/openai

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/macpaw-openai).**

2,862 stars · 511 forks · Swift · mit

## Links

- GitHub: https://github.com/MacPaw/OpenAI
- awesome-repositories: https://awesome-repositories.com/repository/macpaw-openai.md

## Topics

`ai` `openai` `openai-api` `spm` `swift` `swiftpackagemanager`

## Description

This is an asynchronous Swift client library for calling OpenAI’s API across Apple platforms. It provides native access to chat completions, image generation and editing, speech synthesis and transcription, text embeddings, and content moderation through a single interface built on Swift’s async-await concurrency model.

The client supports structured output generation by constraining model responses to a provided JSON schema, and enables real-time consumption of generated text through streaming responses delivered as an AsyncSequence. It includes a thread-based conversation model for managing assistant workflows, with support for creating and running assistants, managing messages and runs, and submitting tool outputs. The library also provides a Model Context Protocol bridge for connecting external tools and data sources at runtime, and a provider compatibility layer that adjusts parsing logic to tolerate non-standard responses from third-party OpenAI-compatible services.

Beyond core API calls, the client handles multipart file uploads for assistants and image variations, computes text embeddings for similarity search, and offers configurable web search parameters. It includes image variation and editing capabilities, speech streaming, and audio translation. The library is distributed as a Swift package and supports cancellation of in-flight requests through Swift’s structured concurrency model.

## Tags

### Artificial Intelligence & ML

- [OpenAI API Clients](https://awesome-repositories.com/f/artificial-intelligence-ml/openai-api-clients.md) — Provides an asynchronous Swift client for calling OpenAI's API across Apple platforms.
- [Streaming Chat Responses](https://awesome-repositories.com/f/artificial-intelligence-ml/ai-chat-clients/streaming-chat-responses.md) — Generates text responses from a language model with optional real-time token-by-token output.
- [Assistant Management APIs](https://awesome-repositories.com/f/artificial-intelligence-ml/assistant-management-apis.md) — Creates and manages assistants, threads, messages, and runs in conversational workflows.
- [Assistant Thread Runners](https://awesome-repositories.com/f/artificial-intelligence-ml/assistant-thread-runners.md) — Starts a new thread and immediately processes it with an assistant. ([source](https://github.com/MacPaw/OpenAI/blob/main/README.md))
- [Chat Completion Services](https://awesome-repositories.com/f/artificial-intelligence-ml/chat-completion-services.md) — Sends prompts and conversation history to language models and returns generated text responses.
- [Conversational AI Assistants](https://awesome-repositories.com/f/artificial-intelligence-ml/conversational-ai-assistants.md) — Creates and manages AI assistants with threads, messages, and tool execution for conversational workflows.
- [API Speech Synthesizers](https://awesome-repositories.com/f/artificial-intelligence-ml/generative-ai-resources/speech-synthesis/web-based-speech-synthesizers/api-speech-synthesizers.md) — Generates audible speech from a text string using a specified voice and audio format. ([source](https://github.com/MacPaw/OpenAI#readme))
- [Image Generation](https://awesome-repositories.com/f/artificial-intelligence-ml/image-generation.md) — Creates new images from text descriptions using a generative AI model. ([source](https://github.com/MacPaw/OpenAI#readme))
- [Conversation Threads](https://awesome-repositories.com/f/artificial-intelligence-ml/language-model-orchestration/conversation-management/conversation-threads.md) — Manages assistant conversations as persistent threads with sequential message and run state tracking.
- [Multimodal Content Generators](https://awesome-repositories.com/f/artificial-intelligence-ml/multimodal-content-generators.md) — Creates images, synthesizes speech, and transcribes or translates audio using generative AI models.
- [Prompt-Based Text Generation](https://awesome-repositories.com/f/artificial-intelligence-ml/prompt-based-text-generation.md) — Sends a text prompt to a language model and returns the generated text response. ([source](https://github.com/MacPaw/OpenAI/blob/main/README.md))
- [Image Description Generators](https://awesome-repositories.com/f/artificial-intelligence-ml/prompt-variation-generators/image-description-generators.md) — Creates new images based on textual descriptions using a DALL-E model. ([source](https://github.com/MacPaw/OpenAI/blob/main/README.md))
- [Unified Audio Transcription](https://awesome-repositories.com/f/artificial-intelligence-ml/speech-transcription/automated-video-transcribers/offline-media-transcribers/unified-audio-transcription.md) — Converts spoken audio into written text, supporting multiple languages and formats. ([source](https://github.com/MacPaw/OpenAI#readme))
- [Streaming Text Generation](https://awesome-repositories.com/f/artificial-intelligence-ml/streaming-text-generation.md) — Delivers generated text tokens incrementally as the model produces them for real-time display. ([source](https://github.com/MacPaw/OpenAI/blob/main/README.md))
- [Multimodal Clients](https://awesome-repositories.com/f/artificial-intelligence-ml/text-to-speech/multimodal-clients.md) — Generates images, synthesizes speech, transcribes audio, and computes text embeddings.
- [Model Context Protocol](https://awesome-repositories.com/f/artificial-intelligence-ml/agentic-systems-frameworks/model-integration-serving/model-integration-interfaces/model-context-protocol.md) — Connects external tools and data sources through a standardized Model Context Protocol interface.
- [Assistant Configuration Updates](https://awesome-repositories.com/f/artificial-intelligence-ml/ai-assistant-configurations/assistant-configuration-updates.md) — Modifies the configuration of an existing AI assistant, such as its model or instructions. ([source](https://github.com/MacPaw/OpenAI/blob/main/README.md))
- [Assistant Creations](https://awesome-repositories.com/f/artificial-intelligence-ml/ai-assistant-configurations/assistant-configuration-updates/assistant-creations.md) — Configures new AI assistants with a model, instructions, and tools for conversational tasks. ([source](https://github.com/MacPaw/OpenAI/blob/main/README.md))
- [Assistant File Uploads](https://awesome-repositories.com/f/artificial-intelligence-ml/assistant-file-uploads.md) — Uploads files, such as PDFs, to be used by an AI assistant as a knowledge source. ([source](https://github.com/MacPaw/OpenAI/blob/main/README.md))
- [MCP Protocol Integrations](https://awesome-repositories.com/f/artificial-intelligence-ml/external-tool-integrations/mcp-protocol-integrations.md) — Integrates external tools and data sources through the Model Context Protocol. ([source](https://github.com/MacPaw/OpenAI/blob/main/README.md))
- [Function Calling Interfaces](https://awesome-repositories.com/f/artificial-intelligence-ml/function-calling-interfaces.md) — Invokes callable functions that a model can execute during a chat completion. ([source](https://github.com/MacPaw/OpenAI/blob/main/README.md))
- [Image Variation and Mixing](https://awesome-repositories.com/f/artificial-intelligence-ml/image-generation/image-editing/image-variation-and-mixing.md) — Generates new images as variations of a provided source image using a generative AI model. ([source](https://github.com/MacPaw/OpenAI#readme))
- [Message Management](https://awesome-repositories.com/f/artificial-intelligence-ml/language-model-orchestration/conversation-management/conversation-threads/message-management.md) — Retrieves all messages belonging to a specific conversation thread for review or processing. ([source](https://github.com/MacPaw/OpenAI/blob/main/README.md))
- [Speech-to-Text Translation](https://awesome-repositories.com/f/artificial-intelligence-ml/machine-learning/speech-processing/speech-datasets/english/speech-to-text-translation.md) — Translates spoken audio from any language into English text. ([source](https://github.com/MacPaw/OpenAI#readme))
- [Structured Output Generators](https://awesome-repositories.com/f/artificial-intelligence-ml/natural-language-code-generators/structured-generation-engines/structured-output-generators.md) — Constrains model responses to conform to a provided JSON schema for reliable programmatic parsing.
- [Text Embedding Generators](https://awesome-repositories.com/f/artificial-intelligence-ml/text-embedding-generators.md) — Converts a text input into a vector representation for use in machine learning tasks. ([source](https://github.com/MacPaw/OpenAI/blob/main/README.md))
- [Text Embeddings](https://awesome-repositories.com/f/artificial-intelligence-ml/text-to-numeric-transformations/text-embeddings.md) — Converts text into numerical vectors for semantic search, clustering, or similarity comparison tasks.
- [Streaming Speech Outputs](https://awesome-repositories.com/f/artificial-intelligence-ml/text-to-speech/speech-to-speech-models/streaming-speech-outputs.md) — Delivers synthesized speech audio data in chunks as it is generated. ([source](https://github.com/MacPaw/OpenAI/blob/main/README.md))
- [Vector Embeddings](https://awesome-repositories.com/f/artificial-intelligence-ml/vector-embeddings.md) — Converts text into numerical vectors using an embedding model for similarity search and clustering.
- [Tool Output Submissions](https://awesome-repositories.com/f/artificial-intelligence-ml/workflow-as-a-tool-exposure/tool-output-submissions.md) — Provides the results of a tool call back to the assistant so it can continue processing. ([source](https://github.com/MacPaw/OpenAI/blob/main/README.md))

### Part of an Awesome List

- [API Speech Synthesizers](https://awesome-repositories.com/f/awesome-lists/media/text-to-speech/api-speech-synthesizers.md) — Converts a text string into spoken audio using a specified voice and format. ([source](https://github.com/MacPaw/OpenAI/blob/main/README.md))
- [Image Editing](https://awesome-repositories.com/f/awesome-lists/ai/image-editing.md) — Modifies existing images by applying changes described in a text prompt. ([source](https://github.com/MacPaw/OpenAI#readme))
- [AI and Machine Learning](https://awesome-repositories.com/f/awesome-lists/ai/ai-and-machine-learning.md) — Client library for interacting with public generative AI APIs.
- [Development Packages](https://awesome-repositories.com/f/awesome-lists/devtools/development-packages.md) — API client for AI services.

### Data & Databases

- [LLM Schema Outputs](https://awesome-repositories.com/f/data-databases/data-governance-modeling/data-modeling-schemas/data-schemas/schema-validated-data-structures/schema-enforced-output-parsers/llm-schema-outputs.md) — Specifies a JSON schema to constrain the format of a model's text response for reliable parsing. ([source](https://github.com/MacPaw/OpenAI#readme))
- [Schema-Constrained Outputs](https://awesome-repositories.com/f/data-databases/json-schema-modeling/schema-validators/llm-json-constraints/schema-constrained-outputs.md) — Provides structured output generation by constraining model responses to a provided JSON schema.
- [Schema-Constrained Sampling](https://awesome-repositories.com/f/data-databases/json-schema-modeling/schema-validators/schema-constrained-sampling.md) — Forces the model to return structured data that conforms to a provided JSON schema. ([source](https://github.com/MacPaw/OpenAI/blob/main/README.md))

### Networking & Communication

- [Streaming Response Architectures](https://awesome-repositories.com/f/networking-communication/communication-protocols-architectures/streaming-architectures/streaming-response-architectures.md) — Delivers incremental tokens or audio chunks via an AsyncSequence for real-time consumption.
- [Incremental Response Clients](https://awesome-repositories.com/f/networking-communication/real-time-telemetry-streams/agent-telemetry-streams/incremental-response-clients.md) — Receives generated text tokens incrementally as the model produces them for real-time display.
- [Message Appending APIs](https://awesome-repositories.com/f/networking-communication/message-threading/message-appending-apis.md) — Provides an API to add new messages to an existing conversation thread for assistant workflows. ([source](https://github.com/MacPaw/OpenAI/blob/main/README.md))
- [Remote Tool Integrations](https://awesome-repositories.com/f/networking-communication/remote-tool-integrations.md) — Connects to external data sources and services via the Model Context Protocol to extend model capabilities. ([source](https://github.com/MacPaw/OpenAI#readme))

### DevOps & Infrastructure

- [Run Status Inspections](https://awesome-repositories.com/f/devops-infrastructure/workflow-run-management/run-status-inspections.md) — Fetches the current state and details of a specific assistant run for monitoring progress. ([source](https://github.com/MacPaw/OpenAI/blob/main/README.md))

### Graphics & Multimedia

- [Mask-Guided Image Editors](https://awesome-repositories.com/f/graphics-multimedia/ai-image-masking/mask-guided-image-editors.md) — Edits images by applying a prompt to areas specified by a mask. ([source](https://github.com/MacPaw/OpenAI/blob/main/README.md))

### Security & Cryptography

- [Content Moderation](https://awesome-repositories.com/f/security-cryptography/content-moderation.md) — Checks text against a content policy and returns category-specific violation scores. ([source](https://github.com/MacPaw/OpenAI/blob/main/openapi.with-code-samples.yml))
- [Content Moderation Policies](https://awesome-repositories.com/f/security-cryptography/content-moderation-policies.md) — Classifies input text to determine if it violates a defined content policy. ([source](https://github.com/MacPaw/OpenAI#readme))

### Web Development

- [Response Structure Standardization](https://awesome-repositories.com/f/web-development/rest-apis/api-response-validation/response-structure-standardization.md) — Creates AI-powered responses with configurable input and output schemas for programmatic use. ([source](https://github.com/MacPaw/OpenAI/blob/main/openapi-generator-config.yaml))
