Correct Chapter 3 to use the official SDK - #15
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| $sender = $this->transport ?? function (array $payload) { | ||
| return $this->client->messages->create(...$payload); | ||
| }; |
There was a problem hiding this comment.
Stop splatting payload into messages->create
sendMessage now calls $this->client->messages->create(...$payload) even though the SDK expects a single associative array. Argument unpacking discards the keys and passes three positional strings, so any real use without a custom transport throws a TypeError before reaching the API. Wrap the array directly in the call to keep the expected signature and restore message sending.
Useful? React with 👍 / 👎.
| $preparedParams = $mw('request', $preparedParams); | ||
| } | ||
|
|
||
| $stream = $this->client->messages->createStream(...$preparedParams); |
There was a problem hiding this comment.
Streaming wrapper unpacks params and will TypeError
The streaming path uses $this->client->messages->createStream(...$preparedParams), which again unpacks the payload into positional arguments. The official SDK’s createStream expects one array, so this call raises a TypeError whenever streaming is used with the real client, breaking the example. Pass the array unchanged instead of unpacking it.
Useful? React with 👍 / 👎.
Summary
Anthropic\ClientAPI, camelCase parameters, and current models while clarifying HTTP-only timeout/pooling examplesTesting
Codex Task