Repository navigation
1.12.0
·
13 commits
to main
since this release
Immutable
release. Only release title and notes can be modified.
What's Changed
- Each error status throws its own subclass of
ErrorException(BadRequestException,AuthenticationException,BillingException,PermissionDeniedException,NotFoundException,ConflictException,RequestTooLargeException,UnprocessableEntityException,RateLimitException,InternalServerException,ApiTimeoutException,OverloadedException), and an error in the middle of a stream throws the subclass of its type. ErrorExceptionhasgetRequestId(),getErrorDetails()andgetRetryAfter(), andcontext()gives each API error's request ID, status, type,retry-afterand error code to Laravel's exception handler and the Laravel packages of Sentry and Flare.- Connection failures throw
ConnectionExceptionand timeoutsTimeoutException, bothTransporterExceptions. withOptions()returns a client whose requests carry extra headers, query parameters, betas, an API version, a workspace, a user profile or a retry count; methods that take only an ID get betas this way.Factory::withAuthToken()sends a bearer token, such as a Workload Identity Federation access token;withWorkspaceId()sendsanthropic-workspace-id.Factory::withBaseUrl()takes a URL the way the official SDKs readANTHROPIC_BASE_URL.withTimeout()andwithConnectTimeout()set the timeouts of the Guzzle client the factory builds.Anthropic::fromEnvironment()builds a client fromANTHROPIC_API_KEYorANTHROPIC_AUTH_TOKEN,ANTHROPIC_BASE_URLandANTHROPIC_CUSTOM_HEADERS.Factory::withConfig()builds a client from a config array. A misspelt key or a value of the wrong type throws, naming the key.Factory::withMaxRetries()retries connection failures, timeouts and 408, 409, 429 and 5xx responses, waiting what the API asks or backing off; retries are off by default.Factory::withMiddleware()runs code around every HTTP attempt; a middleware that throwsRetryableExceptionsends the request again.Factory::withLogger()logs each request, response and retry to a PSR-3 logger, without bodies, headers or query strings.request()sends a request to any API path, returning aRawResponse;iterate()onmodels(),batches()andfiles()walks every page of a list.RefusalFallbackMiddlewareretries a refused Messages request on the fallback models you list, redeeming the refusal's fallback credit; streamed requests pass through for now.OpenTelemetryMiddlewaretraces each request with OpenTelemetry's GenAI attributes and sends the trace context.Client::settings()returns what a client sends with every request, never its key.- The Models responses have
isRetired(),isRetiring(),isRetirementOverdue()andretirementDate(). - The fake's
withOptions()shares its queue, andassertSentWithOptions()checks a request's options.RawResponse::fake()answers raw requests, and the list fakes walk withiterate().ClientFake::onConnection()gives a fake per connection, withassertSentOn()andassertNotSentOn().
Fixes
- A list in a query, such as the models list's
lifecyclefilter, is now sent askey[]=, so the API applies it. - A mid-stream error sent as a plain string throws
ErrorException. - A header set twice under different capitalization sends only the later value.
getErrorType()returns null for an error type that isn't a string.- A key or token given to
Anthropic::client(), the factory,withConfig()orwithOptions()stays out of a stack trace's arguments, which error trackers such as Flare collect.
UPGRADING.md lists the changes that can affect code written against 1.10.
Full Changelog: 1.10.0...1.12.0