Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/phpaisdk/anthropic/llms.txt

Use this file to discover all available pages before exploring further.

The PHP AI SDK Anthropic provider connects your PHP application to Anthropic’s Claude models. It integrates directly with the aisdk/core package and exposes every Claude capability — including streaming, tool calling, structured output via forced tool use, extended reasoning, and multimodal inputs — through a clean, consistent API.

Quickstart

Install the package and make your first Claude API call in under five minutes.

Configuration

Set API keys, base URL, version headers, and custom HTTP options.

Capabilities

Explore text generation, streaming, tool calling, structured output, and more.

API Reference

Full method signatures for the Anthropic facade, provider, and options classes.

What’s included

Text Generation

Generate text with any Claude model using system prompts and multi-turn messages.

Streaming

Stream responses chunk-by-chunk over server-sent events.

Tool Calling

Give Claude tools and let it invoke them with structured arguments.

Structured Output

Return typed JSON objects by adapting Claude’s tool-use API.

Reasoning

Enable extended thinking with configurable token budgets.

Multimodal

Attach images and documents to messages via URL or base64.

Getting started

1

Install via Composer

composer require aisdk/anthropic
2

Set your API key

export ANTHROPIC_API_KEY=sk-ant-...
3

Generate your first response

use AiSdk\Anthropic;
use AiSdk\Generate;

$result = Generate::text('Explain closures in PHP.')
    ->model(Anthropic::model('claude-sonnet-4'))
    ->run();

echo $result->text;

Build docs developers (and LLMs) love