{"id":22703793,"url":"https://github.com/nathanborror/swift-openai","last_synced_at":"2026-05-03T19:31:15.761Z","repository":{"id":267373920,"uuid":"899632962","full_name":"nathanborror/swift-openai","owner":"nathanborror","description":"A Swift client library for interacting with OpenAI's API.","archived":false,"fork":false,"pushed_at":"2025-08-08T20:02:37.000Z","size":2512,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-08T20:29:20.833Z","etag":null,"topics":["gpt","llm","openai","swift"],"latest_commit_sha":null,"homepage":"https://platform.openai.com","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nathanborror.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-12-06T17:11:01.000Z","updated_at":"2025-08-08T20:02:40.000Z","dependencies_parsed_at":"2025-01-15T23:07:31.386Z","dependency_job_id":"2be1ce90-32fa-4380-9c2e-b12ae4b695b2","html_url":"https://github.com/nathanborror/swift-openai","commit_stats":null,"previous_names":["nathanborror/swift-openai"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/nathanborror/swift-openai","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathanborror%2Fswift-openai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathanborror%2Fswift-openai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathanborror%2Fswift-openai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathanborror%2Fswift-openai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nathanborror","download_url":"https://codeload.github.com/nathanborror/swift-openai/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathanborror%2Fswift-openai/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32582471,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T06:36:36.687Z","status":"ssl_error","status_checked_at":"2026-05-03T06:36:09.306Z","response_time":103,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gpt","llm","openai","swift"],"created_at":"2024-12-10T08:12:41.987Z","updated_at":"2026-05-03T19:31:15.756Z","avatar_url":"https://github.com/nathanborror.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"Images/Animal.png\" width=\"256\"\u003e\n\n# Swift OpenAI\n\nAn unofficial Swift client library for interacting with [OpenAI's API](https://platform.openai.com).\n\n## Requirements\n\n- Swift 5.9+\n- iOS 16+\n- macOS 13+\n- watchOS 9+\n- tvOS 16+\n\n## Installation\n\nAdd the following to your `Package.swift` file:\n\n```swift\nPackage(\n    dependencies: [\n        .package(url: \"https://github.com/nathanborror/swift-openai\", branch: \"main\"),\n    ],\n    targets: [\n        .target(\n            name: \"YourApp\",\n            dependencies: [\n                .product(name: \"OpenAI\", package: \"swift-openai\"),\n            ]\n        ),\n    ]\n)\n```\n\n## Usage\n\n### Chat Completion\n\n```swift\nimport OpenAI\n\nlet client = Client(apiKey: OPENAI_API_KEY)\n\nlet req = ChatRequest(\n    messages: [.init(text: \"Hello, OpenAI!\", role: .user)],\n    model: \"gpt-4o\"\n)\n\ndo {\n    let response = try await client.chatCompletions(request)\n    print(response)\n} catch {\n    print(error)\n}\n```\n\n### List models\n\n```swift\nimport OpenAI\n\nlet client = Client(apiKey: OPENAI_API_KEY)\n\ndo {\n    let response = try await client.models()\n    print(response.data.map { $0.id }.joined(separator: \"\\n\"))\n} catch {\n    print(error)\n}\n```\n\n### Command Line Interface\n\n```\n$ make\n$ ./openai\nOVERVIEW: A utility for interacting with the OpenAI API.\n\nUSAGE: openai \u003csubcommand\u003e\n\nOPTIONS:\n  --version               Show the version.\n  -h, --help              Show help information.\n\nSUBCOMMANDS:\n  models                  Returns available models.\n  chat                    Returns a reponse to a chat prompt.\n  transcribe              Returns an audio transcription.\n\n  See 'cli help \u003csubcommand\u003e' for detailed help.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnathanborror%2Fswift-openai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnathanborror%2Fswift-openai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnathanborror%2Fswift-openai/lists"}