Back to Blog
Guide - .NET Development

Claude Integration CLI, API, SDK, and Azure Foundry

As AI becomes central to software development, choosing the right integration method for Claude can significantly impact your project's success. This guide breaks down each option for .NET developers in the public procurement sector.

01

Claude Code (CLI)

The Terminal-Native Experience

$_

What is it?

Claude Code is Anthropic's command-line agentic coding tool. It lives in your terminal, understands your codebase, and helps you code faster through natural language commands.

⚑

Agentic by Design

Claude Code doesn't just answer questionsβ€”it executes tasks, modifies files, runs commands, and handles entire git workflows autonomously.

πŸ“‚

Context-Aware

It reads your project structure, understands relationships between files, and maintains conversation history throughout your session.

πŸ–₯️

Terminal-Native

Perfect for developers who live in the command line, integrating seamlessly with bash, git, and other CLI tools.

Installation
# macOS/Linux (recommended)
curl -fsSL https://claude.ai/install.sh | sh

# Or via npm (deprecated but still works)
npm install -g @anthropic-ai/claude-code
When to Use

Best For

Interactive coding sessions, code reviews, refactoring, debugging, git workflow automation, learning new codebases, and quick prototyping.

When to Avoid

Not For

Production applications needing programmatic AI integration, automated pipelines requiring API responses, or applications needing fine-grained control over parameters.

02

Claude API

Direct HTTP Access

{}

What is it?

The Claude API is the foundational RESTful interface at https://api.anthropic.com. It's the raw HTTP endpoint that all other integrations ultimately use.

🌐

Universal Compatibility

Works with any programming language that can make HTTP requests. No SDK dependencies required.

πŸŽ›οΈ

Full Control

Direct access to all parameters, headers, and response handling. Complete flexibility over every aspect of the request.

β—‹

Stateless

Each request is independent; you manage conversation history yourself. Full control over context management.

Basic Example (cURL)
curl https://api.anthropic.com/v1/messages \
  --header "x-api-key: $ANTHROPIC_API_KEY" \
  --header "anthropic-version: 2023-06-01" \
  --header "content-type: application/json" \
  --data '{
    "model": "claude-sonnet-4-5",
    "max_tokens": 1024,
    "messages": [
      {"role": "user", "content": "Analyze this tender document for compliance issues"}
    ]
  }'
When to Use Raw API
Direct HTTP Access Scenarios

Languages without official SDK support, serverless environments with strict dependency constraints, learning/understanding how Claude's API works internally, or custom HTTP clients and proxy scenarios.

03

Claude SDK

The Developer-Friendly Wrapper

#

What is it?

Anthropic provides official SDKs for Python, TypeScript, Java, Go, C#, Ruby, and PHP. These SDKs wrap the API, providing type safety, automatic retries, streaming support, and error handling.

Important Note
C# SDK Version History

As of version 10+, the Anthropic NuGet package is the official SDK. Earlier versions (3.x and below) were the community-built tryAGI SDK, which has moved to tryAGI.Anthropic.

Installation
dotnet add package Anthropic
Basic Usage (C#)
using Anthropic;
using Anthropic.Models.Messages;

AnthropicClient client = new();

MessageCreateParams parameters = new()
{
    MaxTokens = 1024,
    Messages =
    [
        new()
        {
            Role = Role.User,
            Content = "Analyze this procurement document for compliance",
        },
    ],
    Model = Model.ClaudeSonnet4_5_20250929,
};

var message = await client.Messages.Create(parameters);
Console.WriteLine(message);
Streaming Support
await foreach (var chunk in client.Messages.CreateStreaming(parameters))
{
    Console.Write(chunk);
}
βœ“

Type Safety

Strongly-typed request/response models. Catch errors at compile time rather than runtime.

↻

Automatic Retries

Built-in exponential backoff for transient failures. Handle rate limits gracefully.

πŸ”Œ

IChatClient Support

Integrates with Microsoft.Extensions.AI.Abstractions for standardized AI interfaces.

04

Comparison Matrix

Side-by-Side Overview

Aspect Claude Code (CLI) API (Direct HTTP) SDK (C#/.NET)
Use Case Interactive coding Universal access Application integration
Learning Curve Low Medium Low
Type Safety N/A None Full
Retry Logic Built-in Manual Built-in
Streaming Native Manual parsing IAsyncEnumerable
Best For Developers Any language .NET applications
Authentication OAuth token or API key API key API key or Auth token
05

Azure AI Foundry

Enterprise Cloud Integration

☁️

What is Azure AI Foundry?

Azure AI Foundry (formerly Azure AI Studio) is Microsoft's unified platform for AI development. As of November 2025, Claude models are available directly through Foundry, making Azure the only cloud provider offering both Claude and GPT frontier models on a single platform.

4.5

Claude Opus 4.5

Most intelligent modelβ€”ideal for complex coding, agents, and enterprise workflows.

S

Claude Sonnet 4.5

Best-in-class for coding and building agents. Balanced performance and cost.

H

Claude Haiku 4.5

Near-frontier performance at one-third the costβ€”perfect for high-volume applications.

Benefit 01

Consolidated Billing

Use existing Azure agreements and MACC (Microsoft Azure Consumption Commitment).

Benefit 02

Enterprise Compliance

Leverage Azure's security, governance, and compliance frameworks.

Benefit 03

Familiar Tooling

Integrate with Azure Monitor, Log Analytics, and Cost Management.

Benefit 04

Single Platform

Access both Claude and GPT models without managing multiple vendor relationships.

API Key Authentication
// Set environment variable
// ANTHROPIC_FOUNDRY_API_KEY=your-azure-api-key

var client = new AnthropicClient
{
    BaseUrl = "https://{resource}.services.ai.azure.com/anthropic"
};
Microsoft Entra ID (Azure AD) Authentication
using Azure.Identity;

// Supports Azure CLI login, Managed Identity, etc.
var credential = new DefaultAzureCredential();
var token = await credential.GetTokenAsync(
    new TokenRequestContext(new[] { "https://cognitiveservices.azure.com/.default" })
);
Environment Variables
# Environment variables for Azure Foundry
export ANTHROPIC_FOUNDRY_RESOURCE={your-resource-name}
# Or full URL:
export ANTHROPIC_FOUNDRY_BASE_URL=https://{resource}.services.ai.azure.com
06

API Key vs Auth Token

Understanding Authentication

This is one of the most confusing aspects of Claude authentication. Let's clarify the differences.

πŸ”‘

API Key (ANTHROPIC_API_KEY)

A static secret string generated in the Anthropic Console. Format: sk-ant-api03-... Sent via the x-api-key HTTP header.

  • Long-lived: Doesn't expire unless revoked
  • Pay-as-you-go: Billed based on token usage
  • Programmatic: Designed for server-to-server communication
  • Workspace-scoped: Can be tied to specific workspaces
🎫

Auth Token (ANTHROPIC_AUTH_TOKEN)

An OAuth 2.0 bearer token obtained through authentication flow. Used with the Authorization: Bearer header.

  • Time-limited: Typically expires after 1 hour
  • Subscription-based: Uses your Claude Pro/Max plan
  • User-scoped: Tied to your personal account
  • Interactive: Designed for tools like Claude Code
API Key

When to Use

Backend services and APIs, automated pipelines, production applications, and team/enterprise environments where billing is centralized.

Auth Token

When to Use

Claude Code CLI sessions, personal development with Claude Pro/Max subscription, and interactive tools that can handle OAuth flows.

The Authentication Hierarchy
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    Authentication Methods                    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                             β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”          β”‚
β”‚  β”‚    API Key      β”‚          β”‚   Auth Token    β”‚          β”‚
β”‚  β”‚ (x-api-key)     β”‚          β”‚ (Authorization) β”‚          β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜          β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜          β”‚
β”‚           β”‚                            β”‚                    β”‚
β”‚           β–Ό                            β–Ό                    β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”          β”‚
β”‚  β”‚ Pay-per-use     β”‚          β”‚ Subscription    β”‚          β”‚
β”‚  β”‚ billing         β”‚          β”‚ (Pro/Max plan)  β”‚          β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜          β”‚
β”‚                                                             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
Common Pitfall
Auth Conflict Warning

If you have both authentication methods configured, you'll see: "Auth conflict: Both a token (ANTHROPIC_AUTH_TOKEN) and an API key (ANTHROPIC_API_KEY) are set. This may lead to unexpected behavior."

Resolution: For Claude Code with subscription, unset ANTHROPIC_API_KEY. For programmatic access, unset ANTHROPIC_AUTH_TOKEN.

Get Started
Choose Your Integration Path

Whether you're building tender analysis systems, document processing pipelines, or intelligent assistants, understanding these integration options ensures you pick the right tool for the job.