Topic
PHP & Laravel LLM Integration
12 posts on php & laravel llm integration — part of api integration on the n4n AI blog.
The openai-php client library: setup and usage
A hands-on tutorial for openai-php client library setup: install via Composer, configure API keys, make chat calls, stream, and use with Laravel.
Testing LLM API calls in Laravel with Http::fake
Practical guide to laravel http fake llm testing: mock OpenAI-compatible chat completions in PHPUnit, assert requests, and verify fallback logic.
Streaming chat completions in Laravel with SSE
Step-by-step guide to laravel sse streaming chat completions in PHP using an OpenAI-compatible LLM gateway with fallback and metering.
Storing API keys securely in Laravel config/services.php
Learn how to store and access a laravel services.php api key securely using environment variables, encryption, and runtime guards in this step-by-step guide.
Retry middleware for Guzzle LLM API requests
Learn how to implement Guzzle retry middleware for LLM API requests in PHP to handle rate limits and transient errors with exponential backoff.
Queueing LLM API calls in Laravel with jobs
Learn how to offload LLM API calls from your Laravel app using queue jobs, with practical code for retries, batching, and failure handling.
Laravel Octane and long-running LLM API requests
Practical guide to handling long-running Laravel Octane LLM API requests without blocking workers: async clients, streaming, queues, and fallback.
Handling rate limits in PHP LLM API clients
Practical guide to handling php rate limit llm api errors in PHP: detect 429s, implement backoff with jitter, client-side throttling, and gateway fallback.
cURL vs Guzzle for calling LLM APIs in PHP
A hands-on comparison of curl vs guzzle llm api php: we examine ergonomics, latency, capabilities, and give a clear verdict for PHP devs building LLM applications.
Laravel's HTTP facade for LLM API integration
A hands-on tutorial for PHP engineers: use Laravel's HTTP facade to integrate LLM APIs with clean code, error handling, and OpenAI-compatible endpoints.
Calling the OpenAI API from PHP with Guzzle
A hands-on tutorial for calling the OpenAI API from PHP using Guzzle. Build a client, stream responses, handle errors, and productionize your integration.
Building a Laravel chatbot backend with n4n
Step-by-step tutorial to build a Laravel chatbot backend with n4n, using OpenAI-compatible endpoints, session history, and streaming.
More topics in api integration
- Function Calling Fundamentals27
- Structured Outputs & JSON Mode19
- cURL LLM API Cookbook15
- Integrating GPT-5, Claude Opus 4.8, Gemini 3, Llama 4 & More via One API15
- Next.js AI Chat Integration (App Router + Vercel AI SDK)15
- FastAPI LLM Backend Integration14
- Go net/http LLM API Client14
- LangChain + OpenAI-Compatible Gateway Integration14
- Node.js OpenAI-Compatible SDK Integration14
- Python + OpenAI-Compatible SDK Integration14
- Rate Limits, Retries & Backoff Strategies14
- React Streaming Chat UI Patterns14