Skip to content

Chat Client Five Random Lines

This example assumes using Anthropic; is in scope and apiKey contains your Anthropic API key.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
using var client = GetAuthenticatedChatClient();

var response = await client.GetResponseAsync(
    messages: [new ChatMessage(ChatRole.User, "Generate 5 random words.")],
    new ChatOptions
    {
        ModelId = DefaultModel,
        ResponseFormat = ChatResponseFormatForType<StringArraySchema>(),
        Tools = new List<AITool>(),
    });

Console.WriteLine(response.ToString());