openai-kit  by dylanshine

Swift package for interacting with the OpenAI API

created 2 years ago
739 stars

Top 47.9% on sourcepulse

GitHubView on GitHub
Project Summary

This Swift package provides a community-driven client for interacting with the OpenAI API, targeting Swift developers building applications that leverage AI capabilities. It simplifies API calls for various OpenAI services, offering a convenient way to integrate advanced AI features into Swift projects.

How It Works

OpenAIKit utilizes Swift's native URLSession or the swift-server/async-http-client for making HTTP requests to the OpenAI API. It abstracts the complexities of request formatting and response parsing, allowing developers to interact with models, completions, embeddings, and more through a clean Swift interface. The package emphasizes secure API key management by recommending environment variables and advising against client-side exposure.

Quick Start & Requirements

  • Add dependency to Package.swift: .package(url: "https://github.com/dylanshine/openai-kit.git", from: "1.0.0")
  • Environment variables OPENAI_API_KEY and OPENAI_ORGANIZATION are recommended.
  • Requires Swift 5.0+ and an OpenAI API key.
  • See: OpenAI API documentation

Highlighted Details

  • Supports Chat, Models, Completions, Edits, Images, Embeddings, Files, Moderations, and Speech to text.
  • Offers flexibility with both URLSession and async-http-client integrations.
  • Implements robust error handling via OpenAIKit.APIErrorResponse.
  • Recommends proxying requests through a backend for client-side applications to protect API keys.

Maintenance & Community

  • Community-maintained project.
  • Active development and contributions are encouraged.

Licensing & Compatibility

  • License: MIT
  • Compatible with commercial and closed-source applications.

Limitations & Caveats

Function calling and fine-tuning features are not yet implemented. The project strongly advises against exposing API keys directly in client-side applications due to security risks.

Health Check
Last commit

11 months ago

Responsiveness

1 day

Pull Requests (30d)
0
Issues (30d)
0
Star History
7 stars in the last 90 days

Explore Similar Projects

Feedback? Help us improve.