Mert Özen Further With Every Line

Blog

Mert Özen's blog posts on software development, backend, frontend, and DevOps.

Series
11 posts found
Getting Started with the Claude API from .NET: Console, API Keys, the Anthropic C# SDK and the First Request
Artificial Intelligence PART 01

Getting Started with the Claude API from .NET: Console, API Keys, the Anthropic C# SDK and the First Request

To use the Claude API from .NET, install version 10 or later of the official Anthropic package on NuGet (13.8.0 today), keep the key in ANTHROPIC_API_KEY and register AnthropicClient as a singleton. Workspaces and key types in the Console, temperature/top_p/top_k removed in API version 2026-10-21, the Models API and a ClaudeCatalogService for Bookstore.Api.

15 Nov 2026 14 min 5
The Claude Messages API in Depth: Roles, Content Blocks, Stop Reasons and Usage
Artificial Intelligence PART 02

The Claude Messages API in Depth: Roles, Content Blocks, Stop Reasons and Usage

The Claude Messages API is stateless, so the whole history is sent on every request; the response is a list of blocks, and stop_reason and usage should be read on every response. Mid-conversation system messages, text/image/PDF blocks, thinking counted in max_tokens, refusal categories, count_tokens, Bookstore's support bot and invoice PDF analysis.

15 Nov 2026 15 min 5
Models, Effort and Adaptive Thinking in Claude: Balancing Quality, Speed and Cost
Artificial Intelligence PART 03

Models, Effort and Adaptive Thinking in Claude: Balancing Quality, Speed and Cost

In Claude, quality, speed and cost are set first by the model (Haiku 5.5, Sonnet 5.5, Opus 5.5, Fable 5.2) and then by output_config.effort; thinking is adaptive on these models and billed as output tokens. Prices as of 15 November 2026, default effort and which thinking can be turned off per model, fast mode, task budgets, and a model × effort evaluation tool for Bookstore's return classification.

15 Nov 2026 15 min 6
Streaming with Claude: CreateStreaming, Events and Server-Sent Events in ASP.NET Core
Artificial Intelligence PART 04

Streaming with Claude: CreateStreaming, Events and Server-Sent Events in ASP.NET Core

To stream a Claude answer you handle the events from client.Messages.CreateStreaming; the usage in message_delta is cumulative and the CancellationToken must be passed to the SDK. Event order, text/thinking/input_json deltas, errors inside the stream, the Bookstore assistant with .NET 10 TypedResults.ServerSentEvents, tests with the documented events and validating partial JSON with eager_input_streaming.

15 Nov 2026 13 min 6
Tool Use with Claude: Client Tools, the Tool Loop, Strict Mode and Server Tools
Artificial Intelligence PART 05

Tool Use with Claude: Client Tools, the Tool Loop, Strict Mode and Server Tools

For tool use in Claude you define each tool with a name, a description and a strict JSON Schema, run the tools while stop_reason is tool_use and send all tool_results back in a single user message; authorization belongs inside the tool. tool_choice any returning 400 on Opus 5.5, parallel calls, web search and tool search, the SDK's tool runner and testing the loop with a fake HttpMessageHandler.

15 Nov 2026 18 min 7
Structured Outputs with Claude: JSON Schema, C# Records and Validation
Artificial Intelligence PART 06

Structured Outputs with Claude: JSON Schema, C# Records and Validation

To tie Claude's answer to a schema you pass a JSON Schema in output_config.format; you generate it from a C# record with the System.Text.Json exporter, add additionalProperties: false, and parse the answer after checking stop_reason. The SDK's Create<T> constraint, nullable fields in the schema, enum casing, refusal and max_tokens, and a Bookstore return request that matches the schema but breaks a business rule.

15 Nov 2026 15 min 8
Prompt Caching in Claude: Cache Breakpoints, TTL and Cutting Costs by up to 90%
Artificial Intelligence PART 07

Prompt Caching in Claude: Cache Breakpoints, TTL and Cutting Costs by up to 90%

For prompt caching in Claude you put stable content (tools, system) first, end it with a cache_control breakpoint and add top-level automatic caching for the conversation; you confirm the cache works with cache_read_input_tokens in usage and with cache diagnostics. 5-minute and 1-hour TTL prices, the 512-token minimum, a cost calculation for 1,000 requests, silent breakers such as DateTime.Now, compaction and context editing.

15 Nov 2026 13 min 6
Message Batches and the Files API: Running Bulk Jobs at Half Price and Uploading Files Once
Artificial Intelligence PART 08

Message Batches and the Files API: Running Bulk Jobs at Half Price and Uploading Files Once

You send thousands of non-urgent Claude requests at a 50% discount with the Message Batches API, match results by custom_id rather than order, and store the batch id so nothing is sent twice; with the Files API you upload a file once and use it by file_id. Four result types, a nightly BackgroundService job, the 24-hour and 29-day limits, expires_in_seconds, file_id security and caching the document block.

15 Nov 2026 13 min 8
Skills, Code Execution and the MCP Connector in the Claude API: Using Ready-Made Capabilities and Remote MCP Servers
Artificial Intelligence PART 09

Skills, Code Execution and the MCP Connector in the Claude API: Using Ready-Made Capabilities and Remote MCP Servers

To produce files such as Excel in the Claude API you send the xlsx skill in container.skills together with the code execution tool and download the file_ids returned from $OUTPUT_DIR with the Files API; a remote MCP server is connected through the mcp_servers and mcp_toolset pair with a beta header. Sandbox limits and pricing, uploading a custom SKILL.md, pause_turn and the container, allowlists, token scope, and the SDK's null and list behavior.

15 Nov 2026 14 min 9
An Overview of Claude Managed Agents: Agents, Environments, Sessions and When to Choose Them
Artificial Intelligence PART 10

An Overview of Claude Managed Agents: Agents, Environments, Sessions and When to Choose Them

In Claude Managed Agents you create the agent once as a versioned definition and open a session pinned to that version on every run; Anthropic manages the loop, the container and the event history, and credentials go into a vault, not the prompt. client.Beta.Agents and Sessions in the C# SDK, agents and cron deployments from files with ant apply, session-hour pricing, and a comparison with your own loop or Agent Framework.

15 Nov 2026 10 min 7
Taking the Claude API to Production: Errors, Rate Limits, Cost Tracking, OpenTelemetry and the IChatClient Bridge
Artificial Intelligence PART 11

Taking the Claude API to Production: Errors, Rate Limits, Cost Tracking, OpenTelemetry and the IChatClient Bridge

When you take the Claude API to production you separate the SDK's typed exceptions starting with the most specific, keep retries in one layer (the SDK), tell the spend cap apart from rate limits, and produce a cost metric from each response's usage. The SDK 13.8 error hierarchy, 529 and 429 retry behavior, double retries with Polly, the cache's effect on ITPM, OpenTelemetry spans and the IChatClient bridge that ignores temperature.

15 Nov 2026 12 min 9
Blog Map