Coze chat requests are bot-centric. Every MEAI chat request needs a bot_id, and the SDK also carries a user_id.
Set the default bot with WithBotId(...).
Set the default user with WithUserId(...).
Or pass bot_id, user_id, and conversation_id through ChatOptions.AdditionalProperties.
If you do not configure a user explicitly, the SDK uses "meai_user" by default.
Chat Completions
1 2 3 4 5 6 7 8 910111213
usingCoze;usingMicrosoft.Extensions.AI;varbotId=Environment.GetEnvironmentVariable("COZE_BOT_ID")!;IChatClientclient=newCozeClient(apiKey).WithBotId(botId).WithUserId("demo-user");varresponse=awaitclient.GetResponseAsync([new ChatMessage(ChatRole.User, "Reply with only the word ok.")]);Console.WriteLine(response.Text);
Streaming
1 2 3 4 5 6 7 8 910111213
usingCoze;usingMicrosoft.Extensions.AI;varbotId=Environment.GetEnvironmentVariable("COZE_BOT_ID")!;IChatClientclient=newCozeClient(apiKey).WithBotId(botId);awaitforeach(varupdateinclient.GetStreamingResponseAsync([new ChatMessage(ChatRole.User, "List three short colors.")])){Console.Write(update.Text);}
Reasoning Content
When Coze returns reasoning text, the SDK exposes it as TextReasoningContent.
1 2 3 4 5 6 7 8 91011121314151617
usingMicrosoft.Extensions.AI;varresponse=awaitclient.GetResponseAsync([new ChatMessage(ChatRole.User, "Explain why the sky looks blue.")]);foreach(varcontentinresponse.Messages.SelectMany(m=>m.Contents)){switch(content){caseTextReasoningContentreasoning:Console.WriteLine($"Reasoning: {reasoning.Text}");break;caseTextContenttext:Console.WriteLine($"Answer: {text.Text}");break;}}
Conversation Reuse
To continue an existing Coze conversation, pass conversation_id through AdditionalProperties.
123456789
varresponse=awaitclient.GetResponseAsync([new ChatMessage(ChatRole.User, "Continue the previous task.")],newChatOptions{AdditionalProperties=newAdditionalPropertiesDictionary{["conversation_id"]=existingConversationId,},});
Tool Calling Caveat
The Coze adapter can send MEAI tool results back to Coze and maps Coze requires-action states to ChatFinishReason.ToolCalls.
At the moment, Coze's MEAI adapter does not yet surface provider-issued tool calls back as FunctionCallContent in the returned MEAI response. In practice, this means response.CallToolsAsync(options) style automatic loops are not available yet even though Coze can signal that tool work is required.