nunodonato/anthropic-php
最新稳定版本:0.1.6
Composer 安装命令:
composer require nunodonato/anthropic-php
包简介
A PHP client for the Anthropic API
README 文档
README
A simple PHP library to connect to Anthropic APIs (Claude).
I created this package to fulfill my own needs on my AI projects. I am aware that there are other similar packages, but either they didn't have all the required features or I just didn't like the implementation and usage.
Features
- Messages API
- Support multi-content messages (Vision)
- Tool usage (beta)
- Completion API (legacy)
- Prompt caching (system message only, for now)
- Helps you build and validate messages/tools data structures before sending to the API
Roadmap
- Streaming
Installation
composer require nunodonato/anthropic-php
Usage
More soon.
Instantiate the client
use NunoDonato\AnthropicAPIPHP\Client; // ... $client = new Client($yourApiKey);
Messages API usage
use NunoDonato\AnthropicAPIPHP\Client; use NunoDonato\AnthropicAPIPHP\Messages; // ... $client = new Client($yourApiKey); $messages = new Messages(); $messages->addUserTextMessage('Hello AI!'); $response = $this->client->messages(Client::MODEL_SONNET, $messages); // you can chain messages $messages->addUserTextMessage('Hello AI!') ->addAssistantTextMessage('Hello human!') ->addUserImageMessage('https://example.com/image.jpg', 'What do you see here?');
Available models
const MODEL_OPUS = 'claude-3-opus-20240229'; const MODEL_SONNET = 'claude-3-sonnet-20240229'; const MODEL_HAIKU = 'claude-3-haiku-20240307'; const MODEL_3_5_SONNET = 'claude-3-5-sonnet-latest'; const MODEL_3_5_HAIKU = 'claude-3-5-haiku-latest'; const MODEL_CLAUDE_2 = 'claude-2.1';
统计信息
- 总下载量: 82
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-04-08