Anthropic

Description

The Anthropic provider integrates Claude chat behind IFlexAIProvider.

Provider capabilities (based on the implementation):

  • Chat completions: ChatAsync(...)

  • Streaming chat: ChatStreamAsync(...)

  • Embeddings: not supported (EmbedAsync(...) throws NotSupportedException)

Important concepts

  • Application code should depend on IFlexAIProvider.

  • Flex generates Queries/Handlers that consume IFlexAIProvider; you only register the provider.

  • Default chat model (when not overridden by request/config): claude-3-5-sonnet-20241022

Implementation note: token usage is estimated when the provider does not return concrete usage counts.

Configuration in DI

services.AddFlexAnthropic(configuration);

appsettings.json

Configuration section: FlexBase:AI:Anthropic

Examples (template-based)

These examples mirror the generated Query and PostBus handler templates. You do not register these types manually.

Query: generate a completion

PostBus handler: generate a completion

Provider considerations

  • Embeddings: not supported; pair Anthropic with OpenAI/Azure OpenAI/Gemini/Ollama for embedding generation.

  • Max tokens: keep MaxTokens conservative to avoid truncation or request failures.

  • Streaming: prefer streaming for UI responsiveness and long completions.

Last updated