{"id":20003450,"url":"https://github.com/nathanborror/swift-gen-kit","last_synced_at":"2025-05-04T15:34:59.108Z","repository":{"id":213759588,"uuid":"734862121","full_name":"nathanborror/swift-gen-kit","owner":"nathanborror","description":"GenKit is a library that abstracts away all the differences across generative AI platforms.","archived":false,"fork":false,"pushed_at":"2025-04-29T18:39:51.000Z","size":266,"stargazers_count":56,"open_issues_count":3,"forks_count":5,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-29T18:45:14.973Z","etag":null,"topics":["anthropic","genai","llm","mistral","ollama","openai","perplexity","swift"],"latest_commit_sha":null,"homepage":"","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":"2023-12-22T20:55:44.000Z","updated_at":"2025-04-29T18:39:54.000Z","dependencies_parsed_at":"2024-04-14T14:41:51.913Z","dependency_job_id":"bf8387e6-48d9-409d-bedc-e69e3b3f04a7","html_url":"https://github.com/nathanborror/swift-gen-kit","commit_stats":null,"previous_names":["nathanborror/genkit","nathanborror/swift-gen-kit"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathanborror%2Fswift-gen-kit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathanborror%2Fswift-gen-kit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathanborror%2Fswift-gen-kit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathanborror%2Fswift-gen-kit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nathanborror","download_url":"https://codeload.github.com/nathanborror/swift-gen-kit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252357396,"owners_count":21735137,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["anthropic","genai","llm","mistral","ollama","openai","perplexity","swift"],"created_at":"2024-11-13T05:25:38.681Z","updated_at":"2025-05-04T15:34:59.087Z","avatar_url":"https://github.com/nathanborror.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Swift GenKit\n\nGenKit abstracts away differences across ai model provider platforms. The goal is to make native Swift prototyping and development with ai fast, easy and fun!\n\n## Swift Package Manager\n\n```swift\n...\ndependencies: [\n    .package(url: \"https://github.com/nathanborror/swift-gen-kit\", branch: \"main\"),\n],\ntargets: [\n    .target(\n        name: \"YOUR_TARGET\",\n        dependencies: [\n            .product(name: \"GenKit\", package: \"swift-gen-kit\"),\n        ]\n    ),\n],\n...\n```\n\n## Usage\n\n```swift\nlet service = AnthropicService(apiKey: \"ANTHROPIC_API_KEY\")\nlet model = Model(id: \"claude-3-5-sonnet-20240620\")\n\n// Chat completion that just generates a single response.\n\nlet request = ChatServiceRequest(\n    model: model,\n    messages: [\n        Message(role: .system, content: \"You are a helpful assistant.\"),\n        Message(role: .user, content: \"Hello!\"),\n    ]\n)\nlet message = try await service.completion(request)\nprint(message)\n\n// Streaming completions may perform multiple generations in a loop\n// if tools are present.\n\nvar request = ChatSessionRequest(service: service, model: model)\nrequest.with(system: \"You are a helpful assistant.\")\nrequest.with(history: [Message(role: .user, content: \"Hello!\")])\n\nlet stream = ChatSession.shared.completionStream(request)\nfor try await message in stream {\n    print(message.content)\n}\n```\n\n## Demo App\n\n[Heat](https://github.com/nathanborror/Heat) is an example of how GenKit can be implemented.\n\n## Features\n\n### Sessions\n\nSessions are the highest level of abstraction and the easiest to use. They run in a loop and call out to tools as needed and send tool responses back to the model until it completes its work.\n\n### Services\n\nServices are a common interface for working across many platforms. They allow you to seamlessly switch out the underlying platform without changing any code.\n\n- [Chat Service](Sources/GenKit/Services/ChatService.swift)\n- [Embedding Service](Sources/GenKit/Services/EmbeddingService.swift)\n- [Image Service](Sources/GenKit/Services/ImageService.swift)\n- [Model Service](Sources/GenKit/Services/ModelService.swift)\n- [Transcription Service](Sources/GenKit/Services/TranscriptionService.swift)\n- [Speech Service](Sources/GenKit/Services/SpeechService.swift)\n\n### Supported Providers\n\nProvider packages are swift interfaces that talk directly to model provider REST APIs. You can use these directly but their APIs vary slightly.\n\n- [Anthropic](https://github.com/nathanborror/swift-anthropic)\n- [ElevenLabs](https://github.com/nathanborror/swift-elevenlabs)\n- [Fal](https://github.com/nathanborror/swift-fal)\n- [Llama](https://github.com/nathanborror/swift-llama)\n- [Mistral](https://github.com/nathanborror/swift-mistral)\n- [Ollama](https://github.com/nathanborror/swift-ollama)\n- [OpenAI](https://github.com/nathanborror/swift-openai)\n- [Perplexity](https://github.com/nathanborror/swift-perplexity)\n\n_GenKit also supports [Grok](https://docs.x.ai/docs/overview), [Groq](https://groq.com) and [DeepSeek](https://api-docs.deepseek.com) which all use a subset of the [swift-openai](https://github.com/nathanborror/swift-openai) package._\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnathanborror%2Fswift-gen-kit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnathanborror%2Fswift-gen-kit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnathanborror%2Fswift-gen-kit/lists"}