openai-php/client
OpenAI PHP is a community-maintained PHP client for the OpenAI API, giving Laravel and PHP applications typed, framework-agnostic access to chat, responses, embeddings, images, audio, files, and streaming, backed by an active community and thousands of GitHub stars.
gpt-4o, gpt-4o-mini) in PHP-based applications, aligning with strategic bets on generative AI, RAG (Retrieval-Augmented Generation), or custom LLM workflows. v0.21.0 extends this with programmatic tool calling and apply_patch tool support in the Responses API, unlocking agentic workflows (e.g., code-editing assistants, autonomous task execution) directly from PHP.responses() and conversations() APIs for real-time interactions (e.g., customer support, internal tools).apply_patch tool enable agents that can execute code, edit files, and chain operations—use cases like coding copilots, automated PR workflows, and DevOps assistants.embeddings()), fine-tuning (fineTuning()), and vector stores for semantic search or knowledge bases. File search tool fixes (null ranking_options, max_num_results) improve RAG reliability.audio()) and image (images()) processing for media-rich applications; web search now returns image results and settings, enabling richer research/summarization products.moderations() for content filtering in public-facing apps.BaseUri, enabling multi-cloud strategies or cost-sharing with existing Azure investments. New cache_write_tokens in usage details gives clearer visibility into prompt-caching costs—useful for FinOps and spend forecasting.createStreamed() for real-time responses). Optimized streamed response processing in v0.21.0 improves performance for latency-sensitive apps.Adopt When:
responses() API, programmatic tool calling, apply_patch, web_search_preview) without waiting for official SDK updates.conversations()) or tool-based workflows (e.g., function calling).Look Elsewhere If:
For Executives:
"This package lets us leverage OpenAI’s cutting-edge models (like gpt-4o) in our PHP/Laravel apps with minimal dev effort, cutting months off AI integration timelines. The latest release adds agentic tool calling and apply_patch—the building blocks for autonomous assistants that can edit code and execute multi-step tasks—directly in our existing stack. It’s battle-tested by 5,800+ GitHub stars, supports our Azure investments, gives us clearer cost visibility via token-cache usage tracking, and future-proofs us for OpenAI’s next-gen APIs—all while reducing technical debt from custom wrappers. The cost? Just a few hours of setup vs. years of maintenance."
For Engineering Leaders:
*"The openai-php/client package gives us a production-ready, feature-complete PHP client for OpenAI’s API, with:
apply_patch (v0.21.0) for agentic workflows, plus fixed file-search and web-search behaviors for reliable RAG and research features.cache_write_tokens surfaced in usage details for prompt-caching cost tracking.For Developers: *"This is the Swiss Army knife for OpenAI in PHP:
$client->responses()->create() handle auth, retries, and rate limits.apply_patch tool—build assistants that execute code and edit files with zero boilerplate.$client->responses()->createStreamed(), now with faster streamed processing.null-safe ranking_options/max_num_results on FileSearchTool and web-search image results/settings support.web_search_preview tool with zero boilerplate.How can I help you explore Laravel packages today?