Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Build LLM-powered apps with the Anthropic Claude API or SDK across Python, TypeScript, Java, Go, Ruby, C#, and PHP.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
php/claude-api/streaming.md
1# Streaming — PHP23## Streaming45> **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:^0.7"`67```php8use Anthropic\Messages\RawContentBlockDeltaEvent;9use Anthropic\Messages\TextDelta;1011$stream = $client->messages->createStream(12model: 'claude-opus-4-8',13maxTokens: 64000,14messages: [15['role' => 'user', 'content' => 'Write a haiku'],16],17);1819foreach ($stream as $event) {20if ($event instanceof RawContentBlockDeltaEvent && $event->delta instanceof TextDelta) {21echo $event->delta->text;22}23}24```2526---2728