Skip to main content
net9.0

Anthropic provider for Prompty — executor and processor for Claude models via the Anthropic Messages API.

Published
Apr 13, 2026
6mo ago
Total Downloads
1.0K
1,000

Install

dotnet add package Prompty.Anthropic --version 2.0.0-alpha.9
ProductVersions
.NET
net9.0

README

Prompty.Anthropic

Anthropic Claude provider for Prompty — executor and processor for Claude models via the Anthropic Messages API. Uses direct HTTP (no SDK dependency) for a lightweight footprint.

Installation

dotnet add package Prompty.Core
dotnet add package Prompty.Anthropic

Quick Start

using Prompty.Core;
using Prompty.Anthropic;

// One-time setup — registers renderers, parser, and Anthropic provider
new PromptyBuilder()
    .AddAnthropic();

// Run a .prompty file
var result = await Pipeline.InvokeAsync("chat.prompty", new Dictionary<string, object>
{
    ["question"] = "Explain quantum computing in simple terms"
});

Console.WriteLine(result);

.prompty Configuration

---
name: claude-chat
model:
  id: claude-sonnet-4-20250514
  provider: anthropic
  apiType: chat
  connection:
    kind: key
    endpoint: https://api.anthropic.com
    apiKey: ${env:ANTHROPIC_API_KEY}
  options:
    temperature: 0.7
    maxOutputTokens: 1024
---
system:
You are a helpful assistant.

user:
{{question}}

Supported Models

Any model available through the Anthropic Messages API:

  • claude-sonnet-4-20250514
  • claude-3-5-sonnet-20241022
  • claude-3-haiku-20240307
  • claude-3-opus-20240229

Features

Feature Supported
Chat completions ✅
Streaming (SSE) ✅
Tool calling ✅
Agent mode (tool loop) ✅
Structured output ✅
Image inputs (base64) ✅
System prompts ✅ (extracted per Anthropic convention)

Authentication

API Key

model:
  connection:
    kind: key
    endpoint: https://api.anthropic.com    # optional, this is the default
    apiKey: ${env:ANTHROPIC_API_KEY}

Agent Mode (Tool Calling)

Anthropic's tool calling follows the same pattern as other providers:

var tools = new Dictionary<string, Func<string, Task<string>>>
{
    ["get_weather"] = async (args) => "72°F and sunny"
};

var result = await Pipeline.TurnAsync(
    agent, inputs, tools, maxIterations: 10);

Architecture Notes

This package uses direct HTTP via HttpClient rather than an Anthropic SDK. This means:

  • Zero external package dependencies (only Prompty.Core)
  • Full control over the Messages API wire format
  • Lightweight — no SDK overhead

Documentation

Visit prompty.ai for full documentation.

License

MIT

Changes from Previous Version

No structural changes between v2.0.0-alpha.8 and v2.0.0-alpha.9.

Adoption Assessment

Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.

This version is marked prerelease. Validate its API and upgrade path before production use.Compatibility metadata lists 1 target framework; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.