Skip to content

Correct Chapter 3 to use the official SDK - #15

Open
dalehurley wants to merge 1 commit into
mainfrom
codex/fix-inaccuracies-in-anthropic-sdk-documentation
Open

Correct Chapter 3 to use the official SDK#15
dalehurley wants to merge 1 commit into
mainfrom
codex/fix-inaccuracies-in-anthropic-sdk-documentation

Conversation

@dalehurley

Copy link
Copy Markdown
Owner

Summary

  • update Chapter 3 guidance to use the official Anthropic\Client API, camelCase parameters, and current models while clarifying HTTP-only timeout/pooling examples
  • refresh Chapter 3 sample scripts and dependencies to target PHP 8.1+ and anthropic-ai/sdk ^0.3 with typed message helpers
  • align the series index description for Chapter 16 with the official SDK feature set

Testing

  • Not run (not requested)

Codex Task

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +47 to +49
$sender = $this->transport ?? function (array $payload) {
return $this->client->messages->create(...$payload);
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant