- PHP 100%
Normalize the copyright line so every extracted LithiumHosting/* and LiBilling/* MIT package attributes to Lithium Holdings, LLC (the corporate entity) instead of the individual author. Third-party packages preserve the original copyright AND add a Lithium Holdings modifications line; MIT's notice-preservation requirement is honored. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|---|---|---|
| config | ||
| src | ||
| composer.json | ||
| LICENSE.md | ||
| README.md | ||
LiBilling Anthropic AI Provider
The Anthropic Claude provider for LiBilling's AI Draft Assist subsystem. Self-registers with App\LiBilling\AIProviderRegistry on boot, installing this package and setting LIBILLING_AI_PROVIDER=anthropic is all that is required to enable AI-assisted reply drafting and ticket summarization.
This package is a thin LiBilling adapter. The actual Messages API plumbing lives in lithiumhosting/laravel-anthropic-api; this one composes prompts and maps generic API exceptions into the LiBilling exception hierarchy.
Features
- Draft generation:
AIProvider::draft()via a forcedsubmit_drafttool withdraft_text,confidence,clarifying_questions, andflagged_concerns - Summarization:
AIProvider::summarize()via a forcedsubmit_summarytool withsummaryandkey_points - Variable-aware prompting: when a
RedactionMapis supplied, the system prompt embeds a glossary instructing the model to use:customerFullName,:domain1,:staffMember1, etc. verbatim - Markdown output: drafts are produced as Markdown that drops directly into the Filament reply editor
- Token + cost metadata: per-call usage tokens are converted to
cost_microsvia the sharedAnthropicModelCatalogfor the monthly cost-cap pre-flight - Exception mapping: generic
AnthropicExceptionsubtypes are translated into LiBilling'sAIProviderExceptionhierarchy so the host UI's error toasts stay consistent across providers
Installation
This package is loaded as a local Composer path repository. No separate installation is needed when developing within the LiBilling monorepo.
For standalone installation:
composer require libilling/libilling-ai-anthropic
Configuration
Publish the config file:
php artisan vendor:publish --tag=libilling-ai-anthropic-config
Config Options
| Key | Env | Default | Description |
|---|---|---|---|
api_key |
ANTHROPIC_API_KEY |
(unset) | Required when LIBILLING_AI_PROVIDER=anthropic |
model |
ANTHROPIC_MODEL |
claude-sonnet-4-6 |
Model identifier, must exist in AnthropicModelCatalog |
version |
ANTHROPIC_VERSION |
2023-06-01 |
Anthropic API version header |
timeout_seconds |
ANTHROPIC_TIMEOUT_SECONDS |
60 |
Wall-clock timeout for the synchronous API call |
max_tokens |
ANTHROPIC_MAX_TOKENS |
2000 |
Output cap. Sized for a single ticket reply or summary |
Usage
Within LiBilling the host resolves app(AIProvider::class) and calls draft() or summarize(); staff never invoke this package directly. The relevant pipeline:
App\Services\AiDraft\GenerateDraft(orGenerateSummary) assembles the request from aTicket.App\LiBilling\AI\Redaction\DefaultRedactorrewrites bodies into:variableplaceholders and produces a companionRedactionMap.AnthropicProvider::draftWithMap()/summarizeWithMap()composes the prompt (with the variable glossary), callsAnthropicClient::messages(), and parses the forced tool-use block.- The response is reverse-substituted via
RedactionMap::reverse()before staff see it.
For local testing without burning API credits, Http::fake() against api.anthropic.com/v1/messages works against the underlying AnthropicClient.
Capabilities
AIProvider::capabilities() reports:
supportsStreaming: false: the provider runs a single synchronous requestsupportsToolUse: true: responses are always delivered via forced tool usemaxContextTokens: pulled fromAnthropicModelCatalogfor the configured model (200k for the current Claude 4 family)maxOutputTokens: mirrors themax_tokensconfig
Dependencies
lithiumhosting/laravel-anthropic-api: Generic Messages API client (HTTP, errors, model catalog, response normalization)
Testing
vendor/bin/sail artisan test --filter=AnthropicProvider
The host application's tests/Feature/Ai/Anthropic/ suite exercises this package end-to-end against Http::fake().
License
LiBilling is (C) Lithium Holdings, LLC. All components except for third-party modules and select packages with their own license are licensed under a Commercial License. Contact licensing@lithiumholdings.com for licensing enquiries. Any dissemination of material herein is prohibited without expressed written consent of Lithium Holdings.
This package, libilling-ai-anthropic is licensed under The MIT License (MIT). Please see License File for more information.
Is it any good?
Yes.
When people first hear about a new product, they frequently ask if it is any good. A Hacker News user remarked:
Note to self: Starting immediately, all raganwald projects will have a "Is it any good?" section in the readme, and the answer shall be "yes.".