lucianotonet/groq-php
A powerful PHP library for seamless integration with the GroqCloud API
v1.3.0
255K downloads/mo
#4876 most downloaded on Packagist
lucianotonet/groq-php
What this package is like to depend on
Last release 1 years ago
03 Jun 2025
Release timing varies
gaps range from 9 days to 4 months
Nearly every release is documented
notes for 17 of 17 stable releases
Nothing withdrawn
no release was ever pulled
2 years old
17 releases · first in 2024
0 releases in the last 12 months
see the full history below
Release timeline
17 releases · Mar 2024 to Jun 2025Releases
latest 17-
v1.3.003 Jun 2025Release notes
Open source →🚀 Release v1.3.0
This release brings significant improvements to the Files/Batches module, including expanded support for batch processing of chat completions and audio operations.
🔄 Breaking Changes in Files/Batches Module
New JSONL Format Requirements (Fixes #14)
- Each line must now follow Groq's official batch format:
{ "custom_id": "your-tracking-id", "method": "POST", "url": "/v1/chat/completions", "body": { "model": "llama-3.1-8b-instant", "messages": [...] } }
File Restrictions
- Only
.jsonlextension is now supported - Removed support for
.json,.txt,.ndjson
✨ New Features
- Batch processing support for:
- Chat completions
- Audio transcription
- Audio translation
- Enhanced validation and error handling
🛠️ Improvements
- Additional MIME types support
- Better JSONL file type detection
- Expanded test coverage
- Updated documentation
📝 Migration Guide
-
Update your JSONL files:
- Add
custom_idfield - Set
methodto "POST" - Use proper endpoint URL
- Move request parameters inside
bodyobject
- Add
-
Supported Endpoints:
/v1/chat/completions/v1/audio/transcriptions/v1/audio/translations
📚 Example JSONL File
{"custom_id": "chat-1", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "llama-3.1-8b-instant", "messages": [{"role": "user", "content": "Hello"}]}} {"custom_id": "audio-1", "method": "POST", "url": "/v1/audio/transcriptions", "body": {"model": "whisper-large-v3", "language": "en", "url": "https://example.com/audio.wav"}}📋 Notes
- Changes only affect the Files/Batches module
- Core library features remain unchanged
- All tests passing: 39 tests, 218 assertions
🔗 Links
Release notes
Open source →Breaking Changes in Files/Batches Module
- Changed JSONL file format requirements for batch processing
- Restricted file extensions to
.jsonlonly (removed support for.json,.txt,.ndjson) - Added stricter validation for file contents and structure
Changed
- Updated Files API validation to properly handle 'batch' purpose
- Added support for additional MIME types: application/x-jsonlines, application/jsonl, application/x-ndjson, application/x-ndjason
- Updated JSONL file format documentation and examples
- Updated tests to use new JSONL format and purpose
- Improved file validation order in FileManager.php
- Fixed JSONL file validation in FileManager to properly check content format
- Enhanced error messages for file type validation
- Improved test coverage for file upload functionality
Added
- New example file: examples/batch-processing.php
- Additional test cases for JSONL file validation
- Improved error messages for file validation
- Test results: 39 tests, 218 assertions (all passing)
- Added more comprehensive validation for JSONL file contents
- Support for audio transcription and translation in batch processing
- Support for chat completions in batch processing
Fixed
- Issue with file type validation in FileManager::validateFile method
- Improved MIME type detection for JSONL files
- Fixed test case for file upload to use correct JSONL format
- Corrected JSONL test file structure to match API requirements
Migration Guide for Files/Batches Module
If you are using the Files/Batches module, you will need to:
- Update your JSONL files to include required fields:
custom_id: Your unique identifier for trackingmethod: Must be "POST"url: One of: /v1/chat/completions, /v1/audio/transcriptions, or /v1/audio/translationsbody: Request parameters matching the endpoint format
- Ensure all files use
.jsonlextension - Update file content to match new validation requirements
- Review the updated documentation for complete format specifications
- Each line must now follow Groq's official batch format:
-
v1.2.025 May 2025 -
v1.1.013 Apr 2025Release notes
Open source →Release Notes: v1.1.0
New features
Text-to-Speech (TTS) API Integration
- Added support for GroqCloud's Text-to-Speech API
- Implemented the
Speechclass with a fluent interface for easy configuration - Added a new
speech()method to theAudioclass - Added support for both English and Arabic TTS models
Implementation details
- Models: Added support for
playai-tts(English) andplayai-tts-arabic(Arabic) - Parameters:
model(): Set the TTS model to useinput(): Define text to convert to speechvoice(): Set voice identifier (e.g., "Bryan-PlayAI")responseFormat(): Define output format (default: "wav")
- Methods:
create(): Returns audio content as streamsave($filePath): Saves audio directly to a file
Example usage
// Save audio to file $result = $groq->audio()->speech() ->model('playai-tts') ->input('Hello, this text will be converted to speech') ->voice('Bryan-PlayAI') ->responseFormat('wav') ->save('output.wav'); // Get as stream (e.g., to send to browser) $audioStream = $groq->audio()->speech() ->model('playai-tts') ->input('This is another example text') ->voice('Bryan-PlayAI') ->create(); header('Content-Type: audio/wav'); header('Content-Disposition: inline; filename="speech.wav"'); echo $audioStream;
Documentation
Updated README.md to include comprehensive documentation about the new TTS functionality.
Additional notes
- Text-to-Speech requires acceptance of terms of use in the GroqCloud console
- For more detailed examples, see
examples/audio-speech.php
-
v1.0.023 Mar 2025Release notes
Open source →GroqPHP v1.0.0
We are thrilled to announce the release of GroqPHP v1.0.0! 🎉
This marks a significant milestone as we celebrate our first anniversary. The initial commit was made on March 22, 2024, and after a year of development and iteration, we are proud to have reached 16,000+ downloads. This achievement is a testament to the growing adoption of our library in the PHP community.
What's New in v1.0.0
The 1.0.0 release represents a stable, feature-rich offering that builds upon previous versions with several significant improvements:
Files and Batch Processing
One of the most significant additions in this release is comprehensive support for the Groq Files and Batch Processing APIs:
-
File Management: Seamlessly upload, list, retrieve, download, and delete JSONL files for batch processing
- Support for large file uploads (up to 100MB)
- Automatic validation of file formats and content
- Comprehensive error handling for all file operations
-
Batch Processing: Process large volumes of requests asynchronously
- Create and manage batch jobs with detailed status tracking
- Support for batch job creation, retrieval, listing, and cancellation
- Detailed error reporting for batch operations
Other Enhancements
- Improved Error Handling: Enhanced exception handling with more descriptive error messages
- Updated Models Support: Added support for the latest Groq models, including Llama 3.1
- Environment Variables: Improved handling of environment variables with better fallbacks
- Comprehensive Testing: Added extensive test suite for all components
- API Stability: Finalized API design with stable interfaces
Under the Hood
- Fixed various warnings and potential type errors
- Added GitHub Actions workflow for automated testing
- Updated deprecated model references
- Enhanced documentation with more examples
Breaking Changes
While we have made efforts to maintain backward compatibility, there are a few breaking changes to be aware of:
- The minimum PHP version requirement remains at ^8.1.0
- Some parameter names have been standardized for consistency
Contributors
We extend our heartfelt thanks to all contributors who have made this release possible:
- Luciano Tonet (@lucianotonet) - Project creator and main developer
- Thomas Georgel (@tgeorgel) - Improvements to audio functionality to prevent forced language setting
- lguichard (@lguichard) - API parameter fixes and improvements
- Joseph G (@JosephGabito) - Documentation improvements
And to all users who have provided valuable feedback and suggestions through issues, including @zachary, @EliasPereirah, @flemzord, and @mmddev87.
Looking Forward
As we move beyond v1.0.0, we remain committed to improving GroqPHP with new features, optimizations, and expanded model support. We encourage you to report issues and contribute to the project on GitHub.
Release notes
Open source →- 23/03/2025 test: Add EnvironmentVariablesTest for GROQ_API_KEY and GROQ_API_BASE
- 23/03/2025 fix: prevent TypeError from unset GROQ_API_BASE environment variable
- 23/03/2025 refactor: Update depracated models on examples and tests to use Llama 3
- 27/02/2025 docs: Update README
- 23/02/2025 fix: Fix general warning - 'The version field is present, it is recommended to leave it out if the package is published on Packagist.'
- 23/02/2025 Add GitHub Actions workflow for running tests
-
-
0.1.223 Feb 2025Release notes
Open source →Release notes
Open source →- 23/02/2025 chore: Bump version to v0.1.2
- 23/02/2025 Merge pull request #11 from lucianotonet/feat/files-and-batches
- 23/02/2025 Apply suggestions from code review
- 23/02/2025 Apply suggestions from code review
- 23/02/2025 Add comprehensive test suite for Groq PHP library
- 23/02/2025 Adds reasoning format options to example
- 23/02/2025 Adds file and batch processing capabilities
-
0.1.120 Feb 2025Release notes
Open source →- 20/02/2025 chore: Bump version to v0.1.1
- 20/02/2025 Improves API key retrieval
-
0.1.018 Feb 2025Release notes
Open source →What's Changed
- Fix - Update completions parameters & various update API by @lguichard in #9
- Add Reasoning feature by @lucianotonet in #10
New Contributors
- @lguichard made their first contribution in #9
Full Changelog: v0.0.10...v0.1.0
Release notes
Open source →- 18/02/2025 chore: bump version to 0.1.0
- 18/02/2025 Merge pull request #10 from lucianotonet/develop
- 18/02/2025 Update temperature input range in reasoning example
- 18/02/2025 Update README with comprehensive configuration options and new reasoning/tool calling documentation
- 18/02/2025 Renames max_tokens to max_completion_tokens
- 18/02/2025 Adds reasoning feature
- 18/02/2025 Merge pull request #9 from lguichard/main
- 18/02/2025 Fixes
- 14/02/2025 Fix - Update completions parameters
-
0.0.1029 Oct 2024Release notes
Open source →What's Changed
- Enable to set API_KEY and BASE_URL via setOptions by @lucianotonet in #8
Full Changelog: v0.0.9...v0.0.10
Release notes
Open source →- 29/10/2024 Update version to 0.0.10 in composer.json, add API key options in README.
- 29/10/2024 Merge pull request #8 from lucianotonet/develop
- 29/10/2024 Merge branch 'hotfix/test-vision-with-url' into main
- 29/10/2024 Merge branch 'hotfix/test-vision-with-url' into develop
- 29/10/2024 Translate messages
- 29/10/2024 hotfix: Update image URL in VisionTest
- 29/10/2024 Merge branch 'feature/apikey-on-runtime' into develop
- 29/10/2024 feat: Update Groq class properties and setOptions method.
- 19/09/2024 feat: Ensure API key is explicitly set during initialization
- 19/09/2024 feat(Vision): add default model and enhance analyze method
- 19/09/2024 feat: add parallel tool calls and additional parameters for flexibility
- 08/09/2024 Update image URL in README for Groq PHP project
-
0.0.907 Sep 2024Release notes
Open source →What's Changed
Add Vision functionality for image analysis and examples:
- Added PHP files for Vision analysis and some examples like Vison Simple, Vision URL, Vision Multiple, and Vision Feedback.
- Implemented forms to upload images or provide image URLs with prompts for analysis on examples.
- fix: Prevent the language to be forced on the transcript endpoint by @tgeorgel in #6
New Contributors
Full Changelog: v0.0.8...v0.0.9
Release notes
Open source →- 06/09/2024 Merge remote-tracking branch 'origin/main'
- 06/09/2024 Fix: Re-added missing parameters on request
- 06/09/2024 Update README.md
- 05/09/2024 Update package URL in README for consistency and clarity.
- 05/09/2024 Add image to README for Groq PHP project
- 04/09/2024 Update README.md
- 04/09/2024 Merge tag 'v0.0.9' and add Vision functionality for image analysis. - Merge tag 'v0.0.9' - Add Vision functionality for image analysis and examples
- 04/09/2024 Merge tag 'v0.0.9'
- 04/09/2024 Merge pull request #6 from tgeorgel/main
- 04/09/2024 Add Vision functionality for image analysis and examples:
- 03/09/2024 fix: Prevent the language to be forced on the transcript endpoint
- 02/08/2024 Update Groq PHP package version to 0.0.8
-
0.0.802 Aug 2024Release notes
Open source →This release includes several enhancements and improvements to the Groq PHP package:
- Enhanced error handling and improved API response management, including a new 'failed_generation' field for errors in JSON object responses
- Updated examples with improved error handling and compatibility with the latest GroqException implementations
- Refreshed README.md with new badges displaying version, total downloads, and license information
- Updated package version to 0.0.8, ensuring access to the latest features and performance enhancements
These updates aim to provide a more robust and user-friendly experience when working with the Groq API through this PHP package.
Full Changelog: v0.0.7...v0.0.8
Release notes
Open source →- 02/08/2024 Update Groq PHP package version to 0.0.8
- 02/08/2024 feat: Update examples
- 02/08/2024 feat: Enhance error handling and improve API response management
- 30/07/2024 chore: Update badges in README.md
-
0.0.724 Jul 2024Release notes
Open source →- 23/07/2024 chore: Bump version to 0.0.7
- 23/07/2024 Test: Validate API key and integrate model listing
- 23/07/2024 Refactor: Enhance Error Handling and Improve Code Quality
- 23/07/2024 docs: Update Changelog
- 23/07/2024 feat: Add list models feature
- 23/07/2024 chore: Update to use $_ENV instead of getenv() for improved reliability
- 23/07/2024 chore: Change GROQ_API_BASE_URL env var to GROQ_API_BASE
-
0.0.620 Jul 2024Release notes
Open source →- 19/07/2024 feat: Add speech-to-text transcription and translation features
-
0.0.504 Jul 2024Release notes
Open source →- 04/07/2024 Merge pull request #4 from lucianotonet/versionfix
- 04/07/2024 Fix version mismatch
- 04/07/2024 Update composer.json
- 20/06/2024 Merge pull request #3 from JosephGabito/main
- 21/06/2024 Update README.md
- 13/06/2024 Docs: Mark Models endpoint as completed (1c9a24d)
- 13/06/2024 Remove unrelated scripts
- 13/06/2024 Docs: Remove max retries from readme
- 13/06/2024 Refatoração: Melhora a legibilidade do código em exemplos
- 13/06/2024 feat: Remove Llama2 references as it is not available anymore
- 18/05/2024 Refactored error handling and added documentation examples for Groq PHP library.
- 17/05/2024 Refactor script filenames for brevity and clarity. Rename CHANGELOG_GENERATOR.sh to CHANGELOG_GEN.sh and CHANGELOG_GENERATOR_AI.sh to CHANGELOG_GEN_AI.sh for concise and consistent naming conventions.
- 17/05/2024 Add Groq API key and base URL to .env.example file
- 16/05/2024 Add Models class and list method for fetching models from API
-
0.0.420 Apr 2024Release notes
Open source →- 20/04/2024 Add examples folder + some improvements: - Add support for response streaming and JSON mode. - Improve error handling with more descriptive errors. - Add usage examples. - Fix bugs related to streaming and JSON mode. - Update minimum PHP version. - Add unit tests.
- 13/04/2024 Fix: Cannot assign bool to property LucianoTonet\GroqPHP\Groq::$baseUrl of type string
- 30/03/2024 Update README
-
0.0.330 Mar 2024Release notes
Open source →- 30/03/2024 Add stream funcionality + some refactor
- 30/03/2024 Add stream funcionality + some refactor
- 28/03/2024 Add Changelog
-
0.0.228 Mar 2024Release notes
Open source →- 28/03/2024 Add some examples and improvements.
- 28/03/2024 Add license file
-
0.0.122 Mar 2024