{"id":26037527,"url":"https://github.com/engali94/groq_swift","last_synced_at":"2026-04-16T21:36:21.482Z","repository":{"id":279295917,"uuid":"938348443","full_name":"engali94/groq_swift","owner":"engali94","description":"Swift SDK for the fast Groq API on Apple platforms and Linux","archived":false,"fork":false,"pushed_at":"2025-03-12T00:45:08.000Z","size":2086,"stargazers_count":12,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-04-08T09:23:18.512Z","etag":null,"topics":["groq-api"],"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/engali94.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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-02-24T20:13:39.000Z","updated_at":"2026-03-17T12:50:03.000Z","dependencies_parsed_at":"2025-02-24T21:34:58.961Z","dependency_job_id":null,"html_url":"https://github.com/engali94/groq_swift","commit_stats":null,"previous_names":["engali94/groq_swift"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/engali94/groq_swift","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/engali94%2Fgroq_swift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/engali94%2Fgroq_swift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/engali94%2Fgroq_swift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/engali94%2Fgroq_swift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/engali94","download_url":"https://codeload.github.com/engali94/groq_swift/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/engali94%2Fgroq_swift/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31905890,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-16T18:22:33.417Z","status":"ssl_error","status_checked_at":"2026-04-16T18:21:47.142Z","response_time":69,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["groq-api"],"created_at":"2025-03-07T08:18:20.207Z","updated_at":"2026-04-16T21:36:21.459Z","avatar_url":"https://github.com/engali94.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GroqSwift\n\n[![CI](https://github.com/engali94/groq_swift/actions/workflows/ci.yml/badge.svg)](https://github.com/engali94/groq_swift/actions/workflows/ci.yml)\n[![Documentation](https://img.shields.io/badge/docs-github.io-blue.svg)](https://engali94.github.io/groq_swift/documentation/groqswift/)\n\n\u003e ⚠️ This is a community-maintained library and is not officially supported by Groq.\n\nA Swift SDK for the Groq API, providing a convenient way to interact with Groq's language models in Swift applications. The SDK is designed to work on both Apple platforms and Linux.\n\n## Demo App\n\nHere's a demo chat application built using GroqSwift:\n\n\u003cimg src=\"Examples/Resources/1.png\" width=\"250\" alt=\"Demo Image 1\"\u003e \u003cimg src=\"Examples/Resources/2.png\" width=\"250\" alt=\"Demo Image 2\"\u003e \u003cimg src=\"Examples/Resources/3.png\" width=\"250\" alt=\"Demo Image 3\"\u003e\n\n## Features\n\n- ✨ Modern async/await API design\n- 🔄 Support for both regular and streaming completions\n- 🛡️ Type-safe request and response models\n- 🐧 Linux compatibility\n- ⚡️ Proper error handling with detailed messages\n- 📱 Support for all Apple platforms\n\n## Installation\n\n### Swift Package Manager\n\nAdd the following to your `Package.swift` file:\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/engali94/groq-swift.git\", from: \"0.1.0\")\n]\n```\n\n## Quick Start\n\nPlease ensure you have set the `GROQ_API_KEY` environment variable, before running the following code, \nplease DON'T store API key in code.\n\n```swift\nimport GroqSwift\n\nlet apiKey = ProcessInfo.processInfo.environment[\"GROQ_API_KEY\"] ?? \"\"\nlet client = GroqClient(apiKey: apiKey)\n\nlet request = ChatCompletionRequest(\n    model: .mixtral8x7bChat,\n    messages: [Message(role: .user, content: \"What is the capital of France?\")],\n    temperature: 0.7\n)\n\nlet response = try await client.createChatCompletion(request)\nprint(response.choices.first?.message.content ?? \"\")\n} catch {\n    print(\"Error: \\(error)\")\n}\n\n// Streaming completion\nfor try await response in await client.createStreamingChatCompletion(request) {\n    if let content = response.choices.first?.delta.content {\n        print(content, terminator: \"\")\n    }\n}\n```\n\n## Advanced Usage\n\n### Message Roles\n\nThe SDK supports all message roles:\n\n```swift\n// System message to set behavior\nlet systemMessage = Message(role: .system, content: \"You are a helpful assistant\")\n\n// User message\nlet userMessage = Message(role: .user, content: \"Hello!\")\n\n// Assistant message\nlet assistantMessage = Message(role: .assistant, content: \"Hi there!\")\n```\n\n### Available Models\n\nUse dot syntax to specify models:\n\n```swift\n// LLaMA models\nlet llamaRequest = ChatCompletionRequest(model: .llama70bChat)\nlet llamaVersatileRequest = ChatCompletionRequest(model: .llama70bVersatile)\n\n// Mixtral models\nlet mixtralRequest = ChatCompletionRequest(model: .mixtral8x7bChat)\nlet mixtralVersatileRequest = ChatCompletionRequest(model: .mixtral8x7bVersatile)\n\n// Gemma models\nlet gemmaRequest = ChatCompletionRequest(model: .gemma7bChat)\nlet gemmaVersatileRequest = ChatCompletionRequest(model: .gemma7bVersatile)\n\n// DeepSeek models\nlet deepseekLlamaRequest = ChatCompletionRequest(model: .deepseekR1DistillLlama70b)\nlet deepseekQwenRequest = ChatCompletionRequest(model: .deepseekR1DistillQwen32b)\n```\n\n### Request Parameters\n\nCustomize your requests with various parameters:\n\n```swift\nlet request = ChatCompletionRequest(\n    model: .mixtral8x7bChat,\n    messages: messages,\n    stream: true,                    // Enable streaming\n    maxCompletionTokens: 100,        // Limit response length\n    temperature: 0.7,                // Control randomness\n    topP: 0.9,                      // Nucleus sampling\n    presencePenalty: 0.5,           // Penalize token presence\n    frequencyPenalty: 0.5,          // Penalize token frequency\n    stop: [\"END\"],                  // Stop sequences\n    user: \"user-123\"                // User identifier\n)\n```\n\n### Error Handling\n\nThe SDK provides detailed error information:\n\n```swift\ndo {\n    let response = try await client.createChatCompletion(request)\n} catch let error as GroqError {\n    switch error {\n    case .invalidRequest(let message):\n        print(\"Invalid request: \\(message)\")\n    case .authenticationError(let message):\n        print(\"Auth error: \\(message)\")\n    case .apiError(let statusCode, let message):\n        print(\"API error \\(statusCode): \\(message)\")\n    case .invalidResponse(let message):\n        print(\"Invalid response: \\(message)\")\n    case .invalidURL:\n        print(\"Invalid URL\")\n    }\n} catch {\n    print(\"Unexpected error: \\(error)\")\n}\n```\n\n## Demo Application\n\nCheck out the [GroqChatDemo](Examples/GroqChatDemo) directory for a complete SwiftUI chat application that demonstrates the SDK's capabilities.\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Requirements\n\n- macOS 13.0+\n- iOS 16.0+\n- watchOS 9.0+\n- tvOS 16.0+\n- visionOS 1.0+\n- Swift 5.9+\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fengali94%2Fgroq_swift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fengali94%2Fgroq_swift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fengali94%2Fgroq_swift/lists"}