Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Groq Php Laravel Package

lucianotonet/groq-php

PHP client for the Groq API. Provides a simple, lightweight way to call Groq LLM endpoints from PHP apps, with support for common chat/completions workflows and easy integration into existing projects.

View on GitHub
Deep Wiki
Context7
v1.3.0

🚀 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 .jsonl extension 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

  1. Update your JSONL files:

    • Add custom_id field
    • Set method to "POST"
    • Use proper endpoint URL
    • Move request parameters inside body object
  2. 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

v1.1.0

Release Notes: v1.1.0

New features

Text-to-Speech (TTS) API Integration

  • Added support for GroqCloud's Text-to-Speech API
  • Implemented the Speech class with a fluent interface for easy configuration
  • Added a new speech() method to the Audio class
  • Added support for both English and Arabic TTS models

Implementation details

  • Models: Added support for playai-tts (English) and playai-tts-arabic (Arabic)
  • Parameters:
    • model(): Set the TTS model to use
    • input(): Define text to convert to speech
    • voice(): Set voice identifier (e.g., "Bryan-PlayAI")
    • responseFormat(): Define output format (default: "wav")
  • Methods:
    • create(): Returns audio content as stream
    • save($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.0

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:

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.

v0.1.0

What's Changed

New Contributors

Full Changelog: https://github.com/lucianotonet/groq-php/compare/v0.0.10...v0.1.0

v0.0.10

What's Changed

Full Changelog: https://github.com/lucianotonet/groq-php/compare/v0.0.9...v0.0.10

v0.0.9

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 https://github.com/lucianotonet/groq-php/pull/6

New Contributors

Full Changelog: https://github.com/lucianotonet/groq-php/compare/v0.0.8...v0.0.9

v0.0.8

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: https://github.com/lucianotonet/groq-php/compare/v0.0.7...v0.0.8

v0.0.6

Add speech-to-text transcription and translation features

This introduces the ability to transcribe and translate spoken words from audio and video files.

Users can now:

  • Transcribe audio and video content into text.
  • Translate spoken words in audio and video content.
  • Provide a prompt for context or to specify the spelling of unfamiliar words.
  • Control the variability of transcriptions and translations with a temperature parameter.
  • Choose from various response formats, including JSON, verbose JSON, and plain text.

This functionality enhances the capabilities of the library, making it more versatile and useful for processing audio and video data.

v0.0.4
v0.0.3

Add stream functionality

v0.0.1

First version.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport
twbs/bootstrap4