Some checks are pending
CI — CoM Config Validation / Validate JSON Configs (push) Waiting to run
CI — CoM Config Validation / Validate YAML Configs (push) Waiting to run
CI — CoM Config Validation / Lint Shell Scripts (push) Waiting to run
CI — CoM Config Validation / Secret Detection (push) Waiting to run
CI — CoM Config Validation / Lint Markdown (push) Waiting to run
CI — CoM Config Validation / Validate CODEOWNERS (push) Waiting to run
Public, sanitized mirror of an AI orchestration command center: agents, skills, MCP servers, slash-command workflows. All infrastructure identifiers, hostnames, mesh IPs/subnets, repo paths, maintainer identity, and hardware fleet specifics scrubbed to <placeholders>; session debug logs and host-specific memory removed. No live credentials. Verified clean by automated leak sweep. See SANITIZATION.md. churchofmalware.org . authorized research only
1.5 KiB
1.5 KiB
Claude API — PHP
Note: The PHP SDK is the official Anthropic SDK for PHP. Tool runner and Agent SDK are not available. Bedrock, Vertex AI, and Foundry clients are supported.
Installation
composer require "anthropic-ai/sdk"
Client Initialization
use Anthropic\Client;
// Using API key from environment variable
$client = new Client(apiKey: getenv("ANTHROPIC_API_KEY"));
Amazon Bedrock
use Anthropic\BedrockClient;
$client = new BedrockClient(
region: 'us-east-1',
);
Google Vertex AI
use Anthropic\VertexClient;
$client = new VertexClient(
region: 'us-east5',
projectId: 'my-project-id',
);
Anthropic Foundry
use Anthropic\FoundryClient;
$client = new FoundryClient(
authToken: getenv("ANTHROPIC_AUTH_TOKEN"),
);
Basic Message Request
$message = $client->messages->create(
model: 'claude-opus-4-6',
maxTokens: 1024,
messages: [
['role' => 'user', 'content' => 'What is the capital of France?'],
],
);
echo $message->content[0]->text;
Streaming
$stream = $client->messages->createStream(
model: 'claude-opus-4-6',
maxTokens: 1024,
messages: [
['role' => 'user', 'content' => 'Write a haiku'],
],
);
foreach ($stream as $event) {
echo $event;
}
Tool Use (Manual Loop)
The PHP SDK supports raw tool definitions via JSON schema. See the shared tool use concepts for the tool definition format and agentic loop pattern.