anthropic-ai/sdk
A PHP SDK for the Anthropic API that lets you call Claude models from Laravel or plain PHP apps, with support for streaming responses, tool use, vision inputs, and typed message building for adding AI features quickly.
Architecture fit
config/services.php and .env, and per-feature configuration (model, max tokens, timeout, retry policy) exposed as config keys.StreamedResponse or an SSE/websocket channel, and output buffering disabled. This is the main architectural seam to design up front.Integration feasibility
composer require. No native extensions, no daemon, no database schema changes. Time-to-first-call is measured in minutes for a developer with an API key.Technical risk
LlmClient interface so the SDK is one adapter, not a pervasive dependency.Key questions
Stack fit
config/anthropic.php (model defaults, timeouts, retries, token ceilings) → AnthropicServiceProvider binding a configured client singleton → a thin LlmService domain wrapper that owns prompt construction, response normalization, logging, and cost accounting → feature code depends only on LlmService.Migration path
LlmClient first, implement it twice (old provider, Anthropic), run both behind a feature flag, and compare outputs on a fixed prompt corpus. Do not attempt a big-bang swap; prompt semantics differ enough that quality regressions are subtle.Compatibility
composer why-not and a dependency-resolution dry run in CI before committing. Re-run after the v1.1.0 bump to confirm no transitive drift.--timeout (60s) will kill streaming or long-generation jobs unless raised per-job.Sequencing
LlmClient interface, fake implementation for tests, cost/token logging.Maintenance
~ minor versions with a scheduled quarterly upgrade review. Budget roughly 1–2 engineer-days per quarter for upgrades and regression testing, more if a major version lands. v1.1.0 should cost well under a day to absorb: bump, run the fixture suite, ship.Support
Scaling
Failure modes
Ramp-up
LlmClient, leave the new profile/enforcement surface unused until it has its own security and compliance review, and hold the existing position on version pinning and abstraction ownership.How can I help you explore Laravel packages today?