This example assumes using Anthropic; is in scope and apiKey contains your Anthropic API key.
1 2 3 4 5 6 7 8 91011121314151617181920212223
usingvarclient=newAnthropicClient(apiKey);varenumerable=client.CreateBetaMessageAsStreamAsync(newBetaCreateMessageParams{Model="claude-sonnet-5-5",Messages=["Once upon a time"],MaxTokens=250,// Effort is the first cost lever: it trades thoroughness against token spend// within one model.OutputConfig=newBetaOutputConfig{Effort=BetaEffortLevel.Low,},});vardeltas=newList<string>();awaitforeach(varresponseinenumerable){Console.Write(response.ContentBlockDelta?.Delta.TextDelta?.Text);deltas.Add(response.ContentBlockDelta?.Delta.TextDelta?.Text??string.Empty);}