n4nAI

Topic

PHP & Laravel LLM Integration

12 posts on php & laravel llm integration — part of api integration on the n4n AI blog.

API integrationTutorial

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.

3 min read
API integrationHow-to

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.

3 min read
API integrationHow-to

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.

3 min read
API integrationHow-to

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.

2 min read
API integrationHow-to

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.

3 min read
API integrationHow-to

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.

4 min read
API integrationGuide

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.

5 min read
API integrationHow-to

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.

4 min read
API integrationComparison

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.

4 min read
API integrationTutorial

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.

3 min read
API integrationTutorial

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.

2 min read
API integrationTutorial

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.

3 min read