Download the PHP package livenetworks/ln-ai-bridge without Composer
On this page you can find all versions of the php package livenetworks/ln-ai-bridge. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package ln-ai-bridge
LN AI Bridge
AI provider abstraction layer for Laravel. Unified interface for Claude, OpenAI, and custom providers — direct Guzzle HTTP, no external SDKs.
Installation
Configuration
Add to your .env:
Quick Start
Single request
With context injection
Context pairs are injected as XML tags into the prompt:
Explicit provider
Conversations
Multi-turn conversations with persistent history, automatic summarization, and usage tracking:
All messages are persisted to the database. History is automatically loaded and included with each request.
Manual history (without ConversationManager)
For apps that manage their own message storage:
Conversation with context binding
Summarization
When a conversation exceeds the configured message threshold, older messages are automatically summarized via an AI call. The summary replaces the old messages in context, keeping the conversation within token limits.
Configure in config/ai-bridge.php:
Tool Use (Function Calling)
The AI can request data from the backend via tools. Tool calls are executed automatically — the caller receives only the final text response.
1. Define tools in the request
2. Implement a tool executor
3. Register executors
Multiple tools in one request
Usage Tracking
Every AI request is automatically logged to ai_usage_log with input/output token counts, provider, and model. Query aggregated usage per tenant or user:
Pass tenant/user context for tracking on direct send() calls:
Disable tracking in .env:
Adding Custom Providers
1. Create the provider class extending AbstractProvider:
2. Register it in a service provider:
3. Add config to config/ai-bridge.php providers array:
Configuration Reference
| Key | Default | Description |
|---|---|---|
ai-bridge.default |
claude |
Default provider |
ai-bridge.providers.claude.api_key |
— | Anthropic API key |
ai-bridge.providers.claude.model |
claude-sonnet-4-20250514 |
Claude model |
ai-bridge.providers.claude.base_url |
https://api.anthropic.com |
Claude API base URL |
ai-bridge.providers.claude.version |
2023-06-01 |
Anthropic API version |
ai-bridge.providers.openai.api_key |
— | OpenAI API key |
ai-bridge.providers.openai.model |
gpt-4o |
OpenAI model |
ai-bridge.providers.openai.base_url |
https://api.openai.com |
OpenAI API base URL |
ai-bridge.logging |
false |
Enable request/response logging |
ai-bridge.defaults.temperature |
0.4 |
Default temperature |
ai-bridge.defaults.max_tokens |
8192 |
Default max tokens |
ai-bridge.defaults.timeout |
60 |
HTTP timeout (seconds) |
ai-bridge.conversation.summarize_threshold |
20 |
Messages before auto-summarization |
ai-bridge.conversation.keep_recent |
6 |
Recent messages to keep unsummarized |
ai-bridge.conversation.summary_max_tokens |
500 |
Max tokens for summary |
ai-bridge.usage.tracking_enabled |
true |
Enable usage tracking |
ai-bridge.retry.enabled |
true |
Enable automatic retry |
ai-bridge.retry.max_retries |
3 |
Max retry attempts |
ai-bridge.retry.base_delay_ms |
1000 |
Base delay in milliseconds |
ai-bridge.retry.multiplier |
2 |
Exponential backoff multiplier |
ai-bridge.retry.retryable_codes |
[429,500,502,503,529] |
HTTP status codes to retry |
Retry
API requests are automatically retried on transient failures with exponential backoff. The caller receives only the final response — retries are transparent.
- Retryable: 429 (rate limit), 500, 502, 503, 529 (Anthropic overloaded)
- Not retryable: 400, 401, 403, 404 (client errors fail immediately)
- Backoff:
base_delay_ms × multiplier^attempt→ default 1s, 2s, 4s - Retry-After: honored on 429 responses (takes priority over backoff)
- Logging: each retry attempt is logged at
warninglevel
Configure in config/ai-bridge.php:
Disable via .env:
License
MIT License — Live Networks DOOEL.
All versions of ln-ai-bridge with dependencies
illuminate/support Version ^11.0|^12.0
illuminate/database Version ^11.0|^12.0
illuminate/http Version ^11.0|^12.0
guzzlehttp/guzzle Version ^7.8