Download the PHP package shawnveltman/laravel-openai without Composer
On this page you can find all versions of the php package shawnveltman/laravel-openai. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-openai
Laravel OpenAI - Multi-Provider AI API Wrapper
A unified Laravel package for interacting with multiple AI provider APIs (OpenAI, Claude/Anthropic, Gemini, and Mistral). Uses Laravel's HTTP facade for seamless testing and mocking, with built-in cost tracking and support for advanced features like extended thinking and reasoning.
Features
- ๐ค Multi-Provider Support: OpenAI, Claude/Anthropic, Gemini, and Mistral
- ๐งช Easy Testing: Built on Laravel's HTTP facade for simple mocking
- ๐ฐ Cost Tracking: Automatic logging of API usage and costs
- ๐ง Extended Thinking: Support for Claude's extended thinking and OpenAI's reasoning effort
- ๐ฏ Unified Interface: Consistent API across all providers
- ๐ผ๏ธ Image Support: Send images to vision-capable models
- ๐ Retry Logic: Automatic handling of rate limits and token limits
Installation
Install via Composer:
Publish and run migrations for cost tracking:
Publish the config file:
Add your API keys to .env:
Usage
Basic Example
Using Thinking Effort
Control the reasoning depth with the ThinkingEffort enum:
Thinking Effort Levels:
MINIMAL: Fast responses, minimal reasoning (0 tokens for Claude, "minimal" for OpenAI)LOW: Basic reasoning (6,000 tokens / "low")MEDIUM: Standard reasoning - default (16,000 tokens / "medium")HIGH: Deep reasoning (25,000 tokens / "high")
JSON Mode
Force responses in JSON format:
Working with Images
System Prompts and Messages
Advanced Configuration
Supported Models
OpenAI
- GPT-5 series:
gpt-5,gpt-5-mini,gpt-5-nano - GPT-4 series:
gpt-4o,gpt-4o-mini,gpt-4-turbo - O-series:
o1,o1-mini,o3,o3-mini,o4-mini
Anthropic Claude
claude-sonnet-4-20250514(default)claude-opus-4- Other Claude models
Google Gemini
gemini-progemini-1.5-pro
Mistral
mistral-largemistral-mediumcodestral
Cost Tracking
The package automatically logs all API calls to the cost_logs table:
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Shawn Veltman
- All Contributors
License
The MIT License (MIT). Please see License File for more information.