ForestHub SDK 0.1.0
C++14 LLM SDK for PC and embedded platforms
Loading...
Searching...
No Matches
foresthub::provider::remote::AnthropicProvider Class Reference

Direct Anthropic Claude provider using the native Messages API (POST /v1/messages). More...

#include <anthropic.hpp>

Inheritance diagram for foresthub::provider::remote::AnthropicProvider:
foresthub::core::Provider foresthub::core::LLMClient

Public Member Functions

 AnthropicProvider (const config::ProviderConfig &cfg, std::shared_ptr< core::HttpClient > http_client)
 Construct an Anthropic provider from configuration.
core::ProviderID ProviderId () const override
 Returns "anthropic" as the provider identifier.
std::string Health () const override
 Check that the Anthropic API is reachable.
std::shared_ptr< core::ChatResponseChat (const core::ChatRequest &req) override
 Send a chat request to the Anthropic Messages API.
bool SupportsModel (const core::ModelID &model) const override
 Check if this provider handles the given model.

Detailed Description

Direct Anthropic Claude provider using the native Messages API (POST /v1/messages).

Supported options: temperature, max_tokens, top_p, top_k. Anthropic requires max_tokens; defaults to 4096 when not explicitly set via WithMaxTokens(). Unsupported options (seed, frequency_penalty, presence_penalty) are silently ignored.

Web search is NOT supported in this version. When a ChatRequest contains a WebSearch tool, it is silently filtered out. Anthropic's server-side web search returns server_tool_use and web_search_tool_result content blocks with encrypted_content tokens that must be passed back verbatim in multi-turn conversations. The SDK's InputItems system does not currently support opaque provider-specific content block passthrough, which would cause HTTP 400 errors in multi-turn agent loops.

Constructor & Destructor Documentation

◆ AnthropicProvider()

foresthub::provider::remote::AnthropicProvider::AnthropicProvider ( const config::ProviderConfig & cfg,
std::shared_ptr< core::HttpClient > http_client )

Construct an Anthropic provider from configuration.

Parameters
cfgProvider configuration (api_key, base_url, supported_models).
http_clientHTTP implementation for API calls.

Member Function Documentation

◆ Chat()

std::shared_ptr< core::ChatResponse > foresthub::provider::remote::AnthropicProvider::Chat ( const core::ChatRequest & req)
overridevirtual

Send a chat request to the Anthropic Messages API.

Parameters
reqChat request with model, input, and options.
Returns
Chat response, or nullptr on error.

Implements foresthub::core::LLMClient.

◆ Health()

std::string foresthub::provider::remote::AnthropicProvider::Health ( ) const
overridevirtual

Check that the Anthropic API is reachable.

Returns
Error message on failure, empty on success.

Implements foresthub::core::Provider.

◆ SupportsModel()

bool foresthub::provider::remote::AnthropicProvider::SupportsModel ( const core::ModelID & model) const
overridevirtual

Check if this provider handles the given model.

Parameters
modelModel identifier to check.
Returns
True if supported_models is empty (accept all) or model is in the list.

Implements foresthub::core::Provider.


The documentation for this class was generated from the following file: