PR #1107: Update Anthropic model defaults and skip sampling params on Claude 4.7+
Contributed by pushpak1300
Part of the ai v1.2.0 release
PR #1107 resolves a breakage between laravel/ai's Anthropic gateway and Anthropic's newest Claude releases, and refreshes the package's default model choices in the same pass. Claude 4.7 and later models reject requests that carry a non-default temperature or top_p with an HTTP 400, which meant agents using #[Temperature] or #[TopP] against those models started failing outright. The gateway now sends sampling parameters only to models that accept them, and the cheapest and smartest default text models move to claude-haiku-5-5 and claude-opus-5-5 respectively. If you're upgrading from v1.1.0, the change is mostly transparent, but there are a few behavioral details worth knowing.
Category: 3 (Fix)
New default models: Haiku 5.5 and Opus 5.5
The cheapestTextModel() and smartestTextModel() fallbacks on AnthropicProvider have been updated:
// Before (v1.1.0)
'claude-haiku-4-5-20251001' // cheapest
'claude-fable-5-1' // smartest
// After
'claude-haiku-5-5' // cheapest
'claude-opus-5-5' // smartest
These defaults only apply when you don't name a model explicitly and haven't overridden the values in configuration. If you pin models in config/ai.php, your values still win:
'providers' => [
'anthropic' => [
'models' => [
'text' => [
'cheapest' => 'claude-haiku-4-5-20251001',
],
],
],
],
The practical effect is that #[UseCheapestModel]-style resolution now lands on Haiku 5.5 instead of a dated Haiku 4.5 snapshot, and smartest resolution lands on Opus 5.5 instead of Fable 5.1.
Why Claude 4.7+ requests failed
Anthropic tightened its API for Claude 4.7 and later: sending a non-default temperature or top_p returns a 400. Because laravel/ai always forwarded those options when the attributes were present, a perfectly valid agent could start throwing as soon as it was pointed at a new model:
#[UseCheapestModel]
#[Temperature(0.7)]
class SummarizerAgent implements Agent
{
use Promptable;
public function instructions(): string
{
return 'Summarize the given text in one sentence.';
}
}
On v1.1.0, once the cheapest default resolved to a 4.7+ generation model, this agent's requests were rejected before generation even started. The failure was confusing because nothing in your code changed — only the default model behind it.
How request building works now
The Anthropic gateway gained a supportsSamplingParameters() check built around this pattern:
/^claude-(3-|(opus|sonnet|haiku)-4(-[0-6])?(-\d{8})?$)/
In practice:
claude-3-*andclaude-opus|sonnet|haiku-4up through 4.6 (including dated snapshots likeclaude-sonnet-4-5-20250929) accept sampling parameters, sotemperatureandtop_pare sent as before.- Claude 4.7+ and the 5.x family —
claude-haiku-5-5,claude-opus-5-5,claude-fable-5-1, and so on — get both keys omitted entirely.#[Temperature]and#[TopP]are silently ignored on those models rather than causing a 400.
There's a second, subtler rule: on supported models, top_p is now only sent when temperature is not set. If an agent defines both #[Temperature(0.7)] and #[TopP(0.8)], temperature wins and top_p is dropped. Previously both keys were forwarded together.
Upgrade impact from v1.1.0
For most applications this is a drop-in patch, but check three things:
- Default drift. If you relied on the cheapest or smartest defaults, your traffic moves to Haiku 5.5 / Opus 5.5. That changes cost, latency, and output characteristics. Pin models or override the config values if you need the old behavior.
- Ignored attributes. On Claude 4.7+ models,
#[Temperature]and#[TopP]no longer error — they're simply not sent. If you depended on sampling for output variance, that variance is gone on those models. top_pprecedence. Agents that set both attributes on a 3.x or 4.0–4.6 model will now only sendtemperature. Re-run any evaluations that tunedtop_palongside a temperature.
No configuration migration is required and no public API changed — the fix is entirely in how Anthropic request bodies are assembled.
Takeaways
- Cheapest default is now
claude-haiku-5-5; smartest default is nowclaude-opus-5-5. temperatureandtop_pare only sent toclaude-3-*and Claude 4.0–4.6 models.- On Claude 4.7+, sampling attributes are ignored instead of triggering HTTP 400 errors.
- When both attributes are set on a supported model,
temperaturewins andtop_pis omitted. - Pin explicit models or override the config defaults to keep behavior stable across upgrades.