1. Go to this page and download the library: Download wpai-inc/anthropic-sdk-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
wpai-inc / anthropic-sdk-php example snippets
$anthropic = new \WpAi\Anthropic\AnthropicAPI($apiKey);
$messages = [
[
'role' => 'user',
'content' => 'How can you help me?',
],
];
$options = [
'model' => 'claude-3-opus-20240229',
'maxTokens' => 1024,
'messages' => $messages,
];
$anthropic->messages()->create($options);