Instructor.NET
0.0.1
dotnet add package Instructor.NET --version 0.0.1
NuGet\Install-Package Instructor.NET -Version 0.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Instructor.NET" Version="0.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Instructor.NET" Version="0.0.1" />
<PackageReference Include="Instructor.NET" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Instructor.NET --version 0.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Instructor.NET, 0.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Instructor.NET@0.0.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Instructor.NET&version=0.0.1
#tool nuget:?package=Instructor.NET&version=0.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Instructor.NET
A .NET port of the Python Instructor library for structured outputs from large language models.
Features
- Strongly typed responses from LLMs
- Built-in support for OpenAI's GPT models
- Easy integration with Azure OpenAI
- JSON schema-based response validation
- Customizable output formatting
Installation
dotnet add package Instructor.NET
Quick Start
- First, create a model that inherits from
ResponseModel:
public class UserProfile : ResponseModel
{
public string Name { get; set; } = string.Empty;
public int Age { get; set; }
public string Email { get; set; } = string.Empty;
[JsonPropertyName("preferred_language")]
public string PreferredLanguage { get; set; } = string.Empty;
}
- Initialize the client with your API key:
var client = new InstructorClient("your-api-key-here");
- Create structured outputs:
var userProfile = await client.CreateStructuredOutput<UserProfile>(
"Create a profile for a software developer named Alice who is 28 years old, " +
"uses alice@example.com, and prefers JavaScript"
);
Console.WriteLine($"Name: {userProfile.Name}");
Console.WriteLine($"Age: {userProfile.Age}");
Console.WriteLine($"Email: {userProfile.Email}");
Console.WriteLine($"Preferred Language: {userProfile.PreferredLanguage}");
Advanced Usage
Custom Temperature and Token Limits
var profile = await client.CreateStructuredOutput<UserProfile>(
"Create a profile for an experienced developer",
temperature: 0.9f,
maxTokens: 1000
);
Using Azure OpenAI
var client = new InstructorClient(
"your-api-key-here",
"https://your-resource-name.openai.azure.com/"
);
Accessing Raw Response
var profile = await client.CreateStructuredOutput<UserProfile>(prompt);
Console.WriteLine($"Raw JSON response: {profile.RawResponse}");
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net9.0
- Microsoft.Extensions.DependencyInjection (>= 9.0.5)
- OpenAI (>= 2.1.0)
- System.Text.Json (>= 9.0.5)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.0.1 | 988 | 6/12/2025 |