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

Client Laravel Package

openai-php/client

Community-maintained PHP client for the OpenAI API. Works with models, responses, chat/conversations, files, images, audio, embeddings, fine-tuning, and more. Simple, typed SDK with streaming support, built for modern PHP and Laravel setups.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • AI/ML Integration Roadmap: Accelerates adoption of OpenAI’s latest features (e.g., Responses API, Vector Stores, Azure compatibility) without reinventing the wheel. Enables rapid prototyping of AI-driven features like chatbots, content generation, or data analysis.
  • Build vs. Buy: Buy—reduces dev time by 60–80% compared to building a custom PHP client. Avoids maintenance overhead of a bespoke solution while supporting all OpenAI endpoints (including deprecated ones for backward compatibility).
  • Use Cases:
    • Customer Support: Integrate AI-powered chatbots (e.g., Responses API + tool calls) into Laravel apps.
    • Content Moderation: Leverage Moderations API for real-time content filtering.
    • Data Processing: Use Embeddings or Vector Stores for semantic search or recommendation engines.
    • Legacy System Modernization: Migrate monolithic PHP apps to AI-enhanced workflows (e.g., auto-generating reports via Completions API).
    • Multi-Cloud Strategy: Supports Azure OpenAI via configurable base URIs, reducing vendor lock-in.
  • Cost Optimization: Centralizes API key management (e.g., environment variables, organization-level access) to streamline billing and compliance.
  • Developer Experience: Reduces cognitive load for backend teams by providing type-safe, fluent PHP methods (e.g., $client->responses()->create()) instead of raw HTTP requests.

When to Consider This Package

  • Adopt if:

    • Your stack is PHP/Laravel (or PHP-heavy) and you need OpenAI integration.
    • You require support for OpenAI’s latest APIs (e.g., Responses, Vector Stores) without waiting for official SDKs.
    • Your team lacks bandwidth to maintain a custom API client but needs production-grade reliability (5.7K stars, MIT license, active maintenance).
    • You need Azure OpenAI compatibility or custom HTTP client configurations (e.g., proxies, retries).
    • You’re building AI features that require tool calls, streaming, or metadata tracking (e.g., user sessions).
  • Look elsewhere if:

    • You’re using Python/Node.js—consider official OpenAI SDKs for tighter integration with those ecosystems.
    • Your project requires real-time multiplayer AI (e.g., collaborative editing)—this package focuses on HTTP-based APIs.
    • You need offline AI capabilities (e.g., local LLMs)—this is a cloud API wrapper.
    • Your team prefers low-code/no-code tools (e.g., LangChain, Retool) over custom PHP integration.
    • 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 AI models (like GPT-4o) in our PHP/Laravel apps without hiring specialized AI engineers. It’s battle-tested by 5.7K developers, supports our multi-cloud strategy (Azure/OpenAI), and cuts integration time from months to weeks. For example, we could roll out an AI-powered customer support chatbot in 2 sprints instead of 6—while keeping costs predictable via centralized API key management. The MIT license and active maintenance also reduce vendor risk."

Key Metrics to Track:

  • Time-to-market for AI features (e.g., chatbots, content moderation).
  • Cost savings from reduced dev effort (vs. custom solution).
  • Feature parity with competitors using Python/Node.js SDKs.

For Engineering Leaders:

*"This is the most mature PHP client for OpenAI, with:

  • Full API coverage: From legacy endpoints (e.g., Completions) to new ones (Responses, Vector Stores).
  • Production-ready: Used by 5.7K projects, with CI/CD, type safety, and streaming support.
  • Flexibility: Works with Guzzle, custom HTTP clients, or PSR-18 discovery. Supports Azure OpenAI out of the box.
  • Dev productivity: Fluent methods (e.g., $client->responses()->create()) reduce boilerplate by 70% vs. raw HTTP calls.

Trade-offs:

  • Requires PHP 8.2+ (aligns with Laravel’s latest LTS).
  • No official OpenAI support, but community-driven and actively maintained.

Recommendation: Use this for all new OpenAI integrations unless you have a specific need for Python/Node.js SDKs."*


For Developers:

*"This package just works—here’s how to get started in 5 minutes:

  1. Install: composer require openai-php/client.
  2. Initialize: $client = OpenAI::client(env('OPENAI_KEY')).
  3. Use it: `$response = $client->responses()->create(['model' => 'gpt-4o', 'input' => 'Hello!']).

Why it’s better than raw HTTP:

  • Type safety: Autocomplete for all OpenAI endpoints (e.g., $client->models()->list()).
  • Streaming: Handle AI responses incrementally (e.g., chatbots).
  • Tool calls: Easily integrate custom functions (e.g., $response->output->function_call->arguments).
  • Debugging: Built-in toArray() for inspecting responses.

Pro tip: Use the factory pattern to configure retries, custom headers, or Azure endpoints:

$client = OpenAI::factory()
    ->withBaseUri('azure-openai.example.com/v1')
    ->withHttpClient(new \GuzzleHttp\Client(['timeout' => 30]))
    ->make();
```"*
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
milesj/emojibase
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