Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Sdk Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit

  • The SDK is a thin, framework-agnostic HTTP client wrapper around the Anthropic Messages API. It maps cleanly onto Laravel's service container: a singleton client bound in a service provider, credentials pulled from config/services.php and .env, and per-feature configuration (model, max tokens, timeout, retry policy) exposed as config keys.
  • Because it is not a Laravel package (no service provider, no facade, no publishable config), it lands in the application layer rather than the framework layer. That is the correct place for a vendor SDK, but it means we own the glue: provider, config, facade or typed wrapper, and queue integration.
  • Primary use cases in a Laravel product are synchronous-in-request (chat completions, classification, extraction) and asynchronous-in-queue (batch summarization, document processing, agentic jobs). The SDK supports both, but only the queue path is safe for anything with meaningful latency.
  • Streaming (server-sent events) does not fit a standard Laravel request/response or Blade rendering model. It requires a dedicated streaming controller, StreamedResponse or an SSE/websocket channel, and output buffering disabled. This is the main architectural seam to design up front.
  • v1.1.0 delta: the release adds enforcement status, actions, and filtering to user-profile endpoints. This is an additive, non-breaking surface that sits entirely outside the completion path our architecture depends on. It does not change the wrapper design, the provider/config shape, or the streaming seam. Unless we have a moderation or abuse-workflow requirement, v1.1.0 is a no-op for our integration.

Integration feasibility

  • Installation is a single 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.
  • Authentication is a bearer API key. Secret management is straightforward (env var, then a secrets manager or Laravel encrypted config for multi-tenant scenarios). Per-tenant key routing is possible but must be built, not configured.
  • The SDK assumes a PSR-18 HTTP client; Laravel ships Guzzle, so transport integration is effectively zero-effort. Proxy, CA bundle, and timeout settings propagate normally.
  • v1.1.0 introduces no new required dependencies and no new authentication mechanism as described, so the dependency-resolution dry run and egress review already planned remain sufficient. If the enforcement endpoints require elevated scopes or admin credentials, that needs separate review — a standard API key should not be granted write access to enforcement actions.
  • Blockers remain minimal. The realistic friction points are the PHP version floor and the absence of first-party Laravel conventions, both of which are a day of wrapper work.

Technical risk

  • Maturity signal is weak. 191 stars and 0 dependents on a vendor-official SDK indicates very limited third-party production validation. We would be an early adopter, and early adopter tax is paid in undocumented edge cases.
  • Versioning and breaking-change exposure. v1.1.0 is a minor release with a feature-only changelog, which matches a sane semver policy and is a mildly positive signal. But a single data point is not a compatibility guarantee: pin exact versions, read changelogs, and budget for periodic upgrades.
  • Release metadata integrity — now corroborated. The recorded last release date (2026-10-15) is in the future relative to normal release metadata, and the v1.1.0 note describes "user profiles," "enforcement status," and "actions" — a vocabulary that does not map to the Anthropic Messages API surface described in this assessment. Two independent anomalies pointing the same direction. Either the feed is unreliable or mis-parsed, or this package has a broader scope than assumed. Confirm directly on GitHub and Packagist before treating any of this as a production dependency.
  • Scope creep. A vendor SDK that grows from inference into account/enforcement administration moves from "one adapter behind an interface" to "a component with privileged, state-changing capabilities." That enlarges the blast radius of a leaked key and widens the security review from prompt data flow to administrative action authorization. Not a blocker for v1.1.0 as an unused feature, but it changes how we scope credentials.
  • Vendor coupling. Migrating off the Anthropic API means rewriting prompt logic, tool schemas, and response parsing. Mitigate with an internal LlmClient interface so the SDK is one adapter, not a pervasive dependency.
  • Cost and rate-limit blast radius. A retry loop without jitter, or a runaway queue, can generate significant spend quickly. Risk is operational, not architectural, but it is the failure mode most likely to reach a finance conversation.
  • Compliance. Prompts and completions leave our infrastructure. Data residency, PII handling, and retention policy need sign-off before production, independent of the SDK's quality. The new user-profile endpoints may return personal data we did not previously transmit — add them to the data-flow review before anyone calls them.

Key questions

  1. What is the actual current stable version, release cadence, and stated backward-compatibility policy? Confirm the release date discrepancy.
  2. Does the SDK's supported PHP range cover every runtime in our fleet, including the oldest service still in support?
  3. Is streaming a required capability in the first release, or can v1 ship request/response only?
  4. Do we need multi-tenant key isolation, and if so, who owns per-tenant key storage and rotation?
  5. What is the acceptable p95 latency budget for in-request calls, and does that force queueing from day one?
  6. Is there an existing internal LLM abstraction, and should this SDK sit behind it?
  7. What is the monthly spend ceiling, and what guardrails (token caps, per-user quotas, kill switch) must exist before launch?
  8. New: The v1.1.0 changelog describes user-profile enforcement endpoints. Is this the correct package's changelog, has the SDK broadened beyond inference, and if so, which credential scopes govern those endpoints?
  9. New: Do any of the enforcement/profile endpoints represent a capability we need, or can we adopt with those code paths explicitly unused and out of scope?

Integration Approach

Stack fit

  • Laravel 10/11/12 with PHP 8.1+ is a comfortable fit. The SDK's PSR-18 dependency, JSON handling, and exception model all align with Laravel idioms; only the wiring is ours to write.
  • Recommended shape: 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.
  • Do not let controllers or Eloquent models touch the SDK directly. The wrapper is what makes vendor swap, testing with fakes, and cost instrumentation tractable.
  • v1.1.0 does not alter this shape. The enforcement/profile surface, if ever used, should be reached through a separate, narrower client or service — not exposed on the same object that every feature calls. Keep the inference wrapper free of administrative calls.

Migration path

  • From raw cURL/Guzzle calls against the REST API: replace the hand-rolled request builders with SDK calls, keep the existing response DTOs, and diff behavior against recorded fixtures before cutover.
  • From another provider's PHP SDK (e.g. OpenAI-compatible clients): introduce 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.
  • From no LLM usage: start with a single read-only, low-risk feature (summarization or classification) rather than a customer-facing chat surface.
  • Upgrade path from an earlier pin to v1.1.0 is additive and should be a drop-in. Still run the existing fixture diff — the changelog is short enough that "feature-only" is an assertion to verify, not to assume.

Compatibility

  • Verify PHP floor against the oldest runtime in the fleet; if the SDK requires a PHP version above it, that becomes a platform upgrade project, not a package install.
  • Confirm the SDK does not pin a Guzzle major that conflicts with other dependencies. Run 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.
  • Check Laravel queue worker compatibility for long-running jobs: default --timeout (60s) will kill streaming or long-generation jobs unless raised per-job.
  • Test against our HTTP proxy and egress allowlist; outbound calls to the vendor domain need explicit approval in most enterprise networks.
  • v1.1.0: verify whether the new endpoints reside on the same host and path prefix as the existing API. A new route may require an egress allowlist amendment, which in enterprise networks is a weeks-long change request, not a code change.

Sequencing

  1. Spike (1 week). Install, make authenticated calls, exercise streaming, measure latency and error behavior under load. Output: go/no-go and a documented risk list. Pin the spike to v1.1.0 so the evaluation reflects current code.
  2. Wrapper and config (1 week). Provider, config, LlmClient interface, fake implementation for tests, cost/token logging.
  3. Pilot feature (2 weeks). One low-risk, internal or async feature behind a flag. Establish baseline metrics: latency, error rate, token spend.
  4. Harden. Retry with backoff and jitter, circuit breaker, per-user quotas, structured logging, alerting on 429/5xx and spend anomalies.
  5. Expand. Additional features only after pilot metrics clear agreed thresholds.
  • No resequencing triggered by v1.1.0. The release does not unlock or block any step.

Operational Impact

Maintenance

  • The SDK is vendor-maintained, which is favorable: API drift is the vendor's problem. Our maintenance burden is the wrapper layer and version pinning.
  • Pin to exact or ~ 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.
  • Track the upstream repository for security advisories and deprecations. With 0 dependents, we will not benefit from community early warning, so we must watch the source directly. The v1.1.0 changelog's terse, single-bullet format reinforces that the changelog alone is not a sufficient monitoring channel — diff the tagged source.
  • Growing surface area means growing review scope. Each minor that adds a domain (like enforcement administration) adds a line to the security and compliance review, even if we never call it.

Support

  • Support model is GitHub issues plus vendor documentation. No commercial SLA on the SDK itself; the SLA covers the API, not the library.
  • Internal ownership must be explicit: one team owns the wrapper, the config contract, and the upgrade calendar. Unowned SDK wrappers rot quickly.
  • Document the error taxonomy (auth, rate limit, overloaded, invalid request, timeout, content policy) and map each to a product behavior. Undocumented error handling is where most LLM features degrade badly in production.
  • v1.1.0 adds error and state semantics for enforcement that nobody here has documented or exercised. If that surface is ever enabled, it needs its own error taxonomy — an enforcement call that silently fails is materially worse than a completion that silently fails.

Scaling

  • Scaling is dominated by the vendor's rate limits, not by our infrastructure. Concurrency must be governed by a token-bucket or queue with bounded worker concurrency per tier.
  • Long-running requests should not occupy PHP-FPM workers. Route everything above a latency threshold through Horizon/Redis queues with explicit per-job timeouts and failure handling.
  • Cost scales linearly with usage. Instrument tokens per request, per tenant, and per feature from day one; retrofitting cost attribution is painful and usually inaccurate.
  • Caching (prompt/response caching for deterministic inputs, prompt caching where the vendor supports it) is the highest-leverage cost control and should be designed into the wrapper, not bolted on.
  • v1.1.0 has no scaling implications for the inference path. Profile/enforcement endpoints, if adopted later, are low-volume administrative calls and would not change the capacity model.

Failure modes

  • Rate limiting (429) and overload (529). Expected under load. Requires exponential backoff with jitter, a bounded retry count, and graceful degradation to a queued or "try later" UX.
  • Timeouts on long generations. Default HTTP timeouts are too short. Set per-call timeouts explicitly; for queued jobs, raise worker timeout above the HTTP timeout or jobs will be killed mid-flight and retried, duplicating spend.
  • Streaming disconnects. SSE connections drop on proxies and mobile networks. The client must detect truncation and either resume or fail cleanly; partial output shown as complete is a correctness bug.
  • Invalid API key or revoked key. Fails 100% of calls. Needs a startup health check and an alert, not a silent feature outage.
  • Context-window overflow. Long inputs will be rejected. Validation and truncation/chunking belong in the wrapper, before the call.
  • Runaway spend. A retry storm or a prompt loop can burn budget in hours. Mandatory: per-tenant quotas, a global spend alarm, and a kill switch that degrades the feature without a deploy.
  • Vendor-side model deprecation. Pinned model names get retired. Track deprecation notices and keep model identifiers in config, never hardcoded.
  • New (v1.1.0): unintended administrative calls. If the enforcement/profile methods exist on the shared client, a coding error or a permissive wrapper could invoke a state-changing endpoint where a completion was intended. Mitigate by keeping those methods unreachable from the inference wrapper and, if used at all, granting them a separate credential.

Ramp-up

  • Developer ramp-up is low: the SDK's surface is small and idiomatic, and anyone who has used an HTTP JSON client is productive within a day.
  • The real learning curve is not the SDK but the surrounding discipline: prompt versioning, evaluation harnesses, cost modeling, and error taxonomy. Plan for those as first-class workstreams, not as follow-up tickets.
  • Estimate: ~1 engineer-week to a working pilot with a competent Laravel developer; ~4–6 engineer-weeks to a hardened, observable, cost-controlled production integration with quota and fallback behavior. v1.1.0 does not move these estimates.
  • Overall recommendation: adopt with guardrails, unchanged in direction and slightly firmer in emphasis. v1.1.0 is a small, additive, backwards-compatible release that does not alter the integration plan — but its changelog describes a domain that does not match the API surface this assessment assumes, which is the second metadata anomaly on this package. Resolve the package-identity and release-feed question before pinning, keep the inference path isolated behind 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.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
uni-method/symfony-lib
tacticmedia/scim-server-bundle
neika-ai/symfony-bundle
mattleads/agent-publishing-bundle
glavweb/framework-bundle
glavweb/extra-bundle
glavweb/api-bundle
glavweb/admin-bundle
adachsoft/api-version-bundle
elsayed85/laravel-api-exceptions
ouhssini/laravel-demo-mode
daworks/ncloud-outbound-mailer-driver
gp247/cms
ignibyte/aic-gates
nexa-merchant/blog
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
cgv/localized-resource