attributes
| source_url | https://github.com/anthropics/skills/blob/6e83444ffacecd38b93d1be8381967de84a427f6/skills/claude-api/php/claude-api/streaming.md |
|---|
Streaming - PHP
Streaming
Requires SDK v0.5.0+. v0.4.0 and earlier used a single
$params` array; calling with named parameters throws `Unknown named parameter $model. Upgrade:composer require "anthropic-ai/sdk"
use Anthropic\Messages\RawContentBlockDeltaEvent;
use Anthropic\Messages\TextDelta;
$stream = $client->messages->createStream(
model: 'claude-opus-5-5',
maxTokens: 64000,
messages: [
['role' => 'user', 'content' => 'Write a haiku'],
],
);
foreach ($stream as $event) {
if ($event instanceof RawContentBlockDeltaEvent && $event->delta instanceof TextDelta) {
echo $event->delta->text;
}
}
Like how this is organised?
Build your own Memory tree on knowen.md: notes, decisions and tasks in one connected markdown graph, shared with your team and your AI agents.