System.ClientModel
1.1.0-beta.2
Prefix Reserved
See the version list below for details.
dotnet add package System.ClientModel --version 1.1.0-beta.2
NuGet\Install-Package System.ClientModel -Version 1.1.0-beta.2
<PackageReference Include="System.ClientModel" Version="1.1.0-beta.2" />
<PackageVersion Include="System.ClientModel" Version="1.1.0-beta.2" />
<PackageReference Include="System.ClientModel" />
paket add System.ClientModel --version 1.1.0-beta.2
#r "nuget: System.ClientModel, 1.1.0-beta.2"
#addin nuget:?package=System.ClientModel&version=1.1.0-beta.2&prerelease
#tool nuget:?package=System.ClientModel&version=1.1.0-beta.2&prerelease
System.ClientModel library for .NET
System.ClientModel
contains building blocks for communicating with cloud services. It provides shared primitives, abstractions, and helpers for .NET service client libraries.
System.ClientModel
allows client libraries built from its components to expose common functionality in a consistent fashion, so that once you learn how to use these APIs in one client library, you'll know how to use them in other client libraries as well.
Getting started
Typically, you will not need to install System.ClientModel
.
it will be installed for you when you install one of the client libraries using it.
Install the package
Install the client library for .NET with NuGet.
dotnet add package System.ClientModel
Prerequisites
None needed for System.ClientModel
.
Authenticate the client
The System.ClientModel
package provides a KeyCredential
type for authentication.
Key concepts
The main shared concepts of System.ClientModel
include:
- Configuring service clients (
ClientPipelineOptions
). - Accessing HTTP response details (
ClientResult
,ClientResult<T>
). - Exceptions for reporting errors from service requests in a consistent fashion (
ClientResultException
). - Customizing requests (
RequestOptions
). - Providing APIs to read and write models in different formats (
ModelReaderWriter
).
Examples
Send a message using the MessagePipeline
A very basic client implementation might use the following approach:
ApiKeyCredential credential = new ApiKeyCredential(key);
ApiKeyAuthenticationPolicy authenticationPolicy = ApiKeyAuthenticationPolicy.CreateBearerAuthorizationPolicy(credential);
ClientPipeline pipeline = ClientPipeline.Create(pipelineOptions, authenticationPolicy);
PipelineMessage message = pipeline.CreateMessage();
message.Apply(requestOptions);
message.MessageClassifier = PipelineMessageClassifier.Create(stackalloc ushort[] { 200 });
PipelineRequest request = message.Request;
request.Method = "GET";
request.Uri = new Uri("https://www.example.com/");
request.Headers.Add("Accept", "application/json");
pipeline.Send(message);
Console.WriteLine(message.Response.Status);
Read and write persistable models
As a library author you can implement IPersistableModel<T>
or IJsonModel<T>
which will give library users the ability to read and write your models.
Example writing an instance of a model.
InputModel model = new InputModel();
BinaryData data = ModelReaderWriter.Write(model);
Example reading a model from json
string json = @"{
""x"": 1,
""y"": 2,
""z"": 3
}";
OutputModel? model = ModelReaderWriter.Read<OutputModel>(BinaryData.FromString(json));
Troubleshooting
You can troubleshoot System.ClientModel
-based clients by inspecting the result of any ClientResultException
thrown from a pipeline's Send
method.
Next steps
Contributing
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repositories using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- System.Memory.Data (>= 1.0.2)
- System.Text.Json (>= 4.7.2)
-
net6.0
- System.Memory.Data (>= 1.0.2)
- System.Text.Json (>= 4.7.2)
NuGet packages (177)
Showing the top 5 NuGet packages that depend on System.ClientModel:
Package | Downloads |
---|---|
Azure.Core
This is the implementation of the Azure Client Pipeline |
|
Azure.Search.Documents
This is the Azure Cognitive Search client library for developing .NET applications with rich search experiences. It enables you to query your indexes, update documents in your indexes, and manage indexes, synonym maps, indexers, data sources, or other service-level resources. |
|
Azure.AI.OpenAI
Azure OpenAI's official extension package for using OpenAI's .NET library with the Azure OpenAI Service. |
|
OpenAI
The official .NET library for the OpenAI service API. |
|
Microsoft.VisualStudio.Services.InteractiveClient
Integrate with Azure DevOps Server and Azure DevOps Services from desktop-based Windows applications that require interactive sign-in by a user. |
GitHub repositories (10)
Showing the top 10 popular GitHub repositories that depend on System.ClientModel:
Repository | Stars |
---|---|
openai/openai-dotnet
The official .NET library for the OpenAI API
|
|
optimajet/WorkflowEngine.NET
WorkflowEngine.NET - component that adds workflow in your application. It can be fully integrated into your application, or be in the form of a specific service (such as a web service).
|
|
Kyrodan/KeeAnywhere
A cloud storage provider plugin for KeePass Password Safe
|
|
SparkDevNetwork/Rock
An open source CMS, Relationship Management System (RMS) and Church Management System (ChMS) all rolled into one.
|
|
microsoft/SqlNexus
SQL Nexus is a tool that helps you identify the root cause of SQL Server performance issues. It loads and analyzes performance data collected by SQL LogScout, SQLDiag or PSSDiag. It can dramatically reduce the amount of time you spend manually analyzing data.
|
|
OData/ODataSamples
Samples: For ODataLib, OData Web API, RESTier, etc.
|
|
martinjw/dbschemareader
Read database metadata (from SqlServer/Oracle/MySql/SQLite/PostgreSql/DB2 etc) into one simple model
|
|
johnstaveley/SecurityEssentials
Raise your baseline in security by using this as your template instead of default Mvc project. Keep your app secure by continuously applying Security rules
|
|
Azure/autorest.csharp
Extension for AutoRest (https://github.com/Azure/autorest) that generates C# code
|
|
suncloudsmoon/TextCraft
Integrates AI tools into Microsoft Word
|
Version | Downloads | Last Updated |
---|---|---|
1.5.0 | 35,140 | 7/7/2025 |
1.5.0-beta.1 | 1,302 | 6/13/2025 |
1.4.2 | 1,495,233 | 6/5/2025 |
1.4.1 | 5,151,887 | 5/9/2025 |
1.4.0 | 852,105 | 5/3/2025 |
1.4.0-beta.6 | 862 | 4/28/2025 |
1.4.0-beta.5 | 821 | 4/23/2025 |
1.4.0-beta.4 | 388 | 4/22/2025 |
1.4.0-beta.3 | 32,549 | 4/17/2025 |
1.4.0-beta.2 | 459 | 4/14/2025 |
1.4.0-beta.1 | 1,117,824 | 3/7/2025 |
1.3.0 | 643,594 | 2/6/2025 |
1.2.1 | 10,562,790 | 10/9/2024 |
1.2.0 | 45,979 | 10/3/2024 |
1.1.0 | 81,945,739 | 9/17/2024 |
1.1.0-beta.7 | 320,610 | 8/14/2024 |
1.1.0-beta.6 | 1,205 | 8/1/2024 |
1.1.0-beta.5 | 596,877 | 7/11/2024 |
1.1.0-beta.4 | 654,999 | 5/16/2024 |
1.1.0-beta.3 | 8,974 | 4/5/2024 |
1.1.0-beta.2 | 4,724 | 2/29/2024 |
1.1.0-beta.1 | 6,877 | 2/1/2024 |
1.0.0 | 194,897,513 | 1/3/2024 |
1.0.0-beta.4 | 717 | 3/12/2024 |
1.0.0-beta.3 | 5,153 | 1/4/2024 |
1.0.0-beta.2 | 665 | 12/14/2023 |
1.0.0-beta.1 | 552 | 11/27/2023 |