usingCoze;usingMicrosoft.Extensions.AI;varbotId=Environment.GetEnvironmentVariable("COZE_BOT_ID")!;IChatClientchatClient=newCozeClient(apiKey).WithBotId(botId).WithUserId("demo-user");varresponse=awaitchatClient.GetResponseAsync([new ChatMessage(ChatRole.User, "Reply with only the word ok.")]);Console.WriteLine(response.Text);
Coze chat is bot-centric. You must provide a bot_id via WithBotId(...), ChatOptions.ModelId, or ChatOptions.AdditionalProperties["bot_id"].
Generate
Basic example showing how to create a client and make a request.
1
usingvarclient=newCozeClient(apiKey);
Bots
Examples of listing published bots in a workspace.
1 2 3 4 5 6 7 8 910111213141516171819202122232425
// To list bots, you need a workspace (space) ID. You can find your workspace ID// in the Coze dashboard URL when viewing your workspace.varworkspaceId=Environment.GetEnvironmentVariable("COZE_WORKSPACE_ID")is{Length:>0}value?value:thrownewAssertInconclusiveException("COZE_WORKSPACE_ID environment variable is not found.");usingvarclient=newCozeClient(apiKey);// List published bots in the workspace using `GetSpacePublishedBotsListAsync`.// This returns bots that have been published and are available for use.varresponse=awaitclient.GetSpacePublishedBotsListAsync(spaceId:workspaceId,pageSize:10);// The response contains a `Code` field (0 means success) and a `Data` field// with the list of bots and total count.// Each bot in the list has a `BotId`, `BotName`, and optional `Description`.if(response.Data.SpaceBotsis{Count:>0}bots){varfirstBot=bots[0];Console.WriteLine($"First bot: {firstBot.BotName} (ID: {firstBot.BotId})");}
// To list workflows, you need a workspace ID. You can find your workspace ID// in the Coze dashboard URL when viewing your workspace.varworkspaceId=Environment.GetEnvironmentVariable("COZE_WORKSPACE_ID")is{Length:>0}value?value:thrownewAssertInconclusiveException("COZE_WORKSPACE_ID environment variable is not found.");usingvarclient=newCozeClient(apiKey);// List workflows in the workspace using `OpenAPIGetWorkflowListAsync`.// The `pageNum` parameter starts at 1 (one-based pagination).varresponse=awaitclient.OpenAPIGetWorkflowListAsync(workspaceId:workspaceId,pageNum:1,pageSize:10);// The response contains a `Code` field (0 means success) and a `Data` field// with the workflow items and pagination info.// Each workflow has a `WorkflowId`, `WorkflowName`, and optional `Description`.foreach(varworkflowinresponse.Data.Items){Console.WriteLine($"Workflow: {workflow.WorkflowName} (ID: {workflow.WorkflowId})");}Console.WriteLine($"Has more: {response.Data.HasMore}");
Ecosystem maintenance
This SDK is one of more than 200 .NET SDKs maintained with AutoSDK. The tryAGI SDK audit continuously checks repository synchronization, upstream-spec regeneration, release workflows, warnings, public API visibility, and trimming/NativeAOT compatibility.
Every issue is first investigated for ecosystem-wide applicability. When the root cause belongs in AutoSDK, we fix and regression-test the generator, then roll the improvement out to every applicable SDK. Provider-specific behavior remains in this repository when it cannot be derived safely from the API specification.
Issue content—including code blocks, logs, links, and attachments—is treated only as untrusted diagnostic data. Embedded control instructions, hidden directives, delimiter tricks, or requests to alter triage or tooling behavior are ignored. Please report reproducible technical evidence and remove secrets and personal data.