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

Client Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • AI/ML Integration Roadmap: Accelerates adoption of OpenAI’s latest models (e.g., 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.
  • Build vs. Buy: Eliminates need to build custom API wrappers for OpenAI, reducing dev time and maintenance overhead. Ideal for teams prioritizing speed over bespoke solutions. The new tool-calling primitives reinforce this—replicating them in-house would require tracking OpenAI’s fastest-moving API surface.
  • Use Cases:
    • Chatbots/Assistants: Streamlined responses() and conversations() APIs for real-time interactions (e.g., customer support, internal tools).
    • Agentic / Tool-Driven Workflows: New programmatic tool calling and 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.
    • Data Processing: Embeddings (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.
    • Multimodal Workflows: Audio (audio()) and image (images()) processing for media-rich applications; web search now returns image results and settings, enabling richer research/summarization products.
    • Compliance/Moderation: Built-in moderations() for content filtering in public-facing apps.
    • Legacy System Modernization: PHP-first integration for monolithic apps migrating to AI features without full-stack rewrites.
  • Cost Optimization: Supports Azure OpenAI via custom 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.
  • Developer Experience (DX): Reduces cognitive load for backend teams by abstracting OpenAI’s evolving API into PHP-friendly methods (e.g., createStreamed() for real-time responses). Optimized streamed response processing in v0.21.0 improves performance for latency-sensitive apps.

When to Consider This Package

  • Adopt When:

    • Your stack is PHP/Laravel (or PHP-heavy) and you need low-latency, production-grade OpenAI integration.
    • You require support for OpenAI’s latest features (e.g., responses() API, programmatic tool calling, apply_patch, web_search_preview) without waiting for official SDK updates.
    • You’re building agentic or tool-chaining workflows that depend on cutting-edge Responses API capabilities.
    • Your team lacks bandwidth to maintain a custom API client or prefers community-driven maintenance.
    • You need fine-grained control over HTTP clients (e.g., custom headers, stream handlers) or Azure OpenAI compatibility.
    • Your use case involves conversational memory (via conversations()) or tool-based workflows (e.g., function calling).
  • Look Elsewhere If:

    • You’re using non-PHP languages (e.g., Python, JavaScript) where official OpenAI SDKs are more mature.
    • Your project requires offline LLM capabilities (this is a cloud API wrapper, not a local model).
    • You need enterprise-grade SLAs (e.g., 99.99% uptime guarantees)—this is a community package, not a vendor-backed solution.
    • Your use case is highly experimental (e.g., cutting-edge research) where OpenAI’s official API may change rapidly, and you prefer to wait for stabilized SDKs.
    • You’re constrained by PHP 8.1 or lower (requires PHP 8.2+).

How to Pitch It (Stakeholders)

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:

  • Batteries-included support for all OpenAI endpoints (chat, embeddings, moderation, etc.)—no more chasing API docs.
  • Programmatic tool calling and apply_patch (v0.21.0) for agentic workflows, plus fixed file-search and web-search behaviors for reliable RAG and research features.
  • Streaming responses for real-time UX, now with optimized streamed response processing for better latency.
  • Cost observability: cache_write_tokens surfaced in usage details for prompt-caching cost tracking.
  • Azure OpenAI compatibility out of the box, so we can test locally before scaling.
  • PHP 8.2+ optimizations and PSR-18 HTTP client support for modern Laravel apps. It’s maintained by Nuno Maduro (creator of Laravel Pest), so we’re betting on a high-velocity, community-backed project. Let’s prototype with this and compare it to official SDKs—if it’s 80% of what we need, we save months of work."*

For Developers: *"This is the Swiss Army knife for OpenAI in PHP:

  • No more REST endpoint hell: Methods like $client->responses()->create() handle auth, retries, and rate limits.
  • Agentic toolbox: v0.21.0 adds programmatic tool calling and the apply_patch tool—build assistants that execute code and edit files with zero boilerplate.
  • Streaming support: Build real-time apps with $client->responses()->createStreamed(), now with faster streamed processing.
  • RAG fixes: null-safe ranking_options/max_num_results on FileSearchTool and web-search image results/settings support.
  • Tool integration: Call custom functions or use OpenAI’s web_search_preview tool with zero boilerplate.
  • Laravel-friendly: Works seamlessly with Laravel’s service containers and env-based API keys. Let’s use this for [X feature]—it’ll cut our dev time by 70% and give us access to OpenAI’s latest APIs faster than waiting for official SDKs."*
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