usingvarclient=newLangSmithClient();usingvaropenAiClient=newOpenAiClient();client.JsonSerializerContext=newSpecialJsonSerializerContext(tryAGI.OpenAI.SourceGenerationContext.Default);// This can be a user input to your appvarquestion="Can you summarize this morning's meetings?";// This can be retrieved in a retrieval stepconststringcontext="During this morning's meeting, we solved all world conflict.";varmessages=new[]{"You are a helpful assistant. Please respond to the user's request only based on the given context.".AsSystemMessage(),$"Question: {question}\\nContext: {context}",};// Create parent runvarparentRunId=Guid.NewGuid();awaitclient.Run.CreateRunAsync(name:"Chat Pipeline",runType:CreateRunRequestRunType.Chain,id:parentRunId,inputs:newDictionary<string,object>{["question"]=question,});// Create child runvarchildRunId=Guid.NewGuid();awaitclient.Run.CreateRunAsync(name:"OpenAI Call",runType:CreateRunRequestRunType.Llm,id:childRunId,parentRunId:parentRunId,inputs:newDictionary<string,object>{["messages"]=messages,});// Generate a completionvarchatCompletion=awaitopenAiClient.Chat.CreateChatCompletionAsync(model:CreateChatCompletionRequestModel.Gpt35Turbo,messages:messages);// End runsawaitclient.Run.UpdateRunAsync(runId:childRunId,outputs:newDictionary<string,object>{["chatCompletion"]=chatCompletion,},endTime:DateTime.UtcNow.ToString("O"));awaitclient.Run.UpdateRunAsync(runId:parentRunId,outputs:newDictionary<string,object>{["answer"]=chatCompletion.Choices[0].Message.Content??string.Empty,},endTime:DateTime.UtcNow.ToString("O"));
usingvarclient=GetAuthorizedClient();usingvaropenAiClient=GetAuthorizedOpenAiClient();client.JsonSerializerContext=newSpecialJsonSerializerContext(tryAGI.OpenAI.SourceGenerationContext.Default);// This can be a user input to your appvarquestion="Can you summarize this morning's meetings?";// This can be retrieved in a retrieval stepconststringcontext="During this morning's meeting, we solved all world conflict.";varmessages=new[]{"You are a helpful assistant. Please respond to the user's request only based on the given context.".AsSystemMessage(),$"Question: {question}\\nContext: {context}",};// Create parent run// var parentRunId = Guid.NewGuid();// await client.Run.CreateRunAsync(// name: "Chat Pipeline",// runType: CreateRunRequestRunType.Chain,// id: parentRunId,// inputs: new Dictionary<string, object>// {// ["question"] = question,// });//// // Create child run// var childRunId = Guid.NewGuid();// await client.Run.CreateRunAsync(// name: "OpenAI Call",// runType: CreateRunRequestRunType.Llm,// id: childRunId,// parentRunId: parentRunId,// inputs: new Dictionary<string, object>// {// ["messages"] = messages,// });// Generate a completionvarchatCompletion=awaitopenAiClient.Chat.CreateChatCompletionAsync(request:newCreateChatCompletionRequest(newCreateChatCompletionRequestVariant2{Messages=messages,Model=ModelIdsSharedEnum.Gpt4oMini,}));// End runs// await client.Run.UpdateRunAsync(// runId: childRunId,// outputs: new Dictionary<string, object>// {// ["chatCompletion"] = chatCompletion,// },// endTime: DateTime.UtcNow.ToString("O"));// await client.Run.UpdateRunAsync(// runId: parentRunId,// outputs: new Dictionary<string, object>// {// ["answer"] = chatCompletion.Choices[0].Message.Content ?? string.Empty,// },// endTime: DateTime.UtcNow.ToString("O"));
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.