定制 alle-ai/anthropic-api-php 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

alle-ai/anthropic-api-php

最新稳定版本:1.3

Composer 安装命令:

composer require alle-ai/anthropic-api-php

包简介

A PHP library for interacting with Anthropic's API

README 文档

README

A PHP library for interacting with Anthropic's API.

Introduction

The Alle-AI anthropic-api-php is a package that provides a convenient and straightforward way to interact with the Anthropic Claude model from your PHP application. For more information contact dickson@alle-ai.com.

Installation

The most recommended way to install Alle-AI anthropic-api-php is via composer:

composer require alle-ai/anthropic-api-php

Usage

After installing the Alle-AI anthropic-api-php package into your project,

// Load your project's composer autoloader (If you aren't already doing so). require_once(__DIR__ . '/vendor/autoload.php');

Authentication

To authenticate your API requests, you will need to provide a valid API key from Anthropic

$api_key = 'your-anthropic-api-key';

Please see the Anthropic API documentation for more details on obtaining your API key.

Example

Integrating Anthropic's Claude Model into your application is now as simple as a few lines of code:

Chat Completion using Claude (claude-2.1)

require_once 'vendor/autoload.php'; // Include the Composer autoloader $api_key = 'your-anthropic-api-key'; $anthropic_version = "2023-06-01"; $anthropic_api = new Alle_AI\Anthropic\AnthropicAPI($api_key, $anthropic_version); $prompt = "How many toes do dogs have?"; $data = array( 'prompt' => "\n\nHuman: ".$prompt."\n\nAssistant:", // Be sure to format prompt appropriately 'model' => 'claude-2.1', 'max_tokens_to_sample' => 300, 'stop_sequences' => array("\n\nHuman:") ); $response = $anthropic_api->generateText($data); echo $response['completion']; // To display only completion // Claude's Response:  // Dogs typically have 4 toes on each of their front paws and 5 toes on each of their back paws, for a total of 18 toes.

Learn more about Anthropic's API.

Note: Anthropic is rolling out Claude slowly and incrementally. Please see here on how to get access.

Support

If you have any questions or feedback, please use the discussion board or you can send a mail to dickson@alle-ai.com.

License

This software is copyright (c) 2023-present Alle-AI | Your All-In-One AI Platform. This software is free to use, copy, modify, merge, publish, distribute. For copyright and license information, please view the LICENSE file.

统计信息

  • 总下载量: 20.61k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 27
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 26
  • Watchers: 1
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固