Weave 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

A PHP SDK for the GroqCloud API that lets developers add fast LLM inference to any PHP app, with chat completions, tool calling, vision, reasoning, audio transcription, text-to-speech, batch processing, and RAG support.

View on GitHub
Deep Wiki
Context7

Groq PHP is a high-performance PHP SDK for integrating GroqCloud’s ultra-fast LLM inference into any PHP application. It provides a clean, comprehensive API for working with models such as DeepSeek, Llama, Mixtral, and Gemma, with optional environment-based configuration.

  • Chat Completions with tool calling, vision, and reasoning support
  • Audio transcription, translation, and text-to-speech
  • Files and batch processing for larger workloads
  • Built-in tools and Compound for web search and code execution
  • RAG, citations, Responses API, prompt caching, and moderation
Frequently asked questions about Groq Php
How do I install and configure lucianotonet/groq-php?
Install it with Composer using composer require lucianotonet/groq-php. Create an API key in the GroqCloud console, then export GROQ_API_KEY (or add it to your .env file) and optionally set GROQ_API_BASE if you need to route traffic through a proxy or gateway. After that you instantiate the client and can call $groq->chat()->completions()->create() in a few lines.
Does groq-php work with Laravel, or do I need a separate Laravel package?
The SDK is framework-agnostic and has no facade, service provider, or global state, so it works fine in Laravel behind your own service-provider binding. The maintainer also publishes a sibling package, groq-laravel, if you want config publishing and facade-style ergonomics. For most applications, binding the client as a singleton from config/groq.php and wrapping it in your own interface is enough.
How do I make a chat completion request with groq-php?
Call $groq->chat()->completions()->create([...]) with a model and a messages array, the same shape as the OpenAI chat API. The response comes back as a decoded PHP array, so the generated text is under choices[0].message.content. Keep the model identifier in configuration rather than hardcoding it, because Groq retires model IDs on its own schedule.
Does groq-php support streaming responses?
Yes, streaming chunks are part of the feature set alongside JSON mode and standard chat completions. In a Laravel app, stream chunks straight to a StreamedResponse or a broadcast event instead of buffering the whole completion, or the latency advantage of Groq is wasted. If you only need structured output, JSON mode with a non-streaming call is usually simpler to test.
How do I implement tool calling with groq-php?
Pass a tools array where each entry declares type function with a name, description, and JSON schema parameters, then read tool_calls off the assistant message, execute the function in your application, and send the result back as a tool-role message. Note that the README states parallel_tool_calls currently has to be forced false in code, which suggests a partially reconciled implementation, so verify multi-tool behaviour during your spike. Treat the tool loop as your own domain code rather than something the SDK owns.
Can groq-php handle audio transcription, text-to-speech, and vision?
Yes, the SDK exposes audio()->transcriptions() and translation plus text-to-speech, and a vision surface that accepts local images up to roughly 4MB or remote URLs up to 20MB. Reasoning models are also supported with raw, parsed, and hidden output formats. The convenience helpers such as vision()->analyze() and reasoning()->analyze() bake in default model choices and message assembly, so override models from config and prefer assembling messages in your own code for production paths.
How do I use the Files and Batch APIs from a Laravel queue?
Upload your JSONL payload through files() and then submit a batch job, which Groq completes within an asynchronous window of up to about 24 hours. That maps naturally onto a queued job that submits the batch plus a scheduled poller that checks status and dispatches follow-up work, rather than blocking a request. Confirm in the source whether any webhook or callback is supported, since polling is the safe assumption.
How does groq-php handle errors, timeouts, and retries?
The README does not document a detailed exception hierarchy, so inspect the thrown exception classes during evaluation and check whether status codes are exposed so you can distinguish retryable 429 and 5xx responses from terminal 4xx errors. Check composer.json for whether timeouts and retry behaviour are configurable on the underlying HTTP client or whether you need to wrap each call. Wrapping the client in your own retry-and-backoff helper is a low-cost safeguard either way.
How do I keep model IDs and the API base URL configurable in groq-php?
Put the API key, base URI, per-capability default models, timeouts, and retry policy in a config file and build the client from it. GROQ_API_BASE is configurable, which lets you point at an egress proxy or gateway for observability and access control. Avoid copying the model IDs from the README examples (llama3-8b-8192, deepseek-r1-distill-llama-70b, and the hardcoded vision default) into your code, because Groq deprecates models and those literals will rot.
Is lucianotonet/groq-php production ready, and what are the alternatives?
It is MIT licensed with a changelog, releases, and a CI tests badge, but the ecosystem is small around 80 stars with no dependents and a single maintainer, so it has not been stress-tested at scale and coverage depth is unclear. Because the Groq API is OpenAI-compatible, your abstraction can be re-pointed at openai-php or prism with modest effort, which limits vendor lock-in. A sensible approach is to spike with this SDK, then own your LlmClient and TranscriptionClient interfaces so the transport stays replaceable.
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.
se7enxweb/flysystem
lampwick/laravel
jeslage/statamic-emojis
micahdshackelford/rmap-laravel
draftsmaninc/draftsman
square-bit/laravel-volition
himito/laravel-mailman
htinlynn/genius-helper
maco-studios/hephaestus
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log