InstructSharp 1.0.0
See the version list below for details.
dotnet add package InstructSharp --version 1.0.0
NuGet\Install-Package InstructSharp -Version 1.0.0
<PackageReference Include="InstructSharp" Version="1.0.0" />
<PackageVersion Include="InstructSharp" Version="1.0.0" />
<PackageReference Include="InstructSharp" />
paket add InstructSharp --version 1.0.0
#r "nuget: InstructSharp, 1.0.0"
#:package InstructSharp@1.0.0
#addin nuget:?package=InstructSharp&version=1.0.0
#tool nuget:?package=InstructSharp&version=1.0.0
InstructSharp
InstructSharp is your go-to .NET library for seamless, provider-agnostic LLM integrations. Whether you’re working with ChatGPT, Claude, Gemini, Grok, DeepSeek or LLaMA, InstructSharp wraps every call in a consistent QueryAsync<T>
pattern and returns crisp, structured JSON objects 📦✨. Just define your POCO schema, pick your model, and you’re ready to 🚀:
- 🔌 Multi-provider support: OpenAI, Anthropic, Google, X.AI, DeepSeek & more
- 🔖 Type-safe outputs: Deserialize straight into your custom classes
- ⚙️ Fully configurable: Tweak temperature, max_tokens, and other settings
- 🛠️ Minimal setup: Install via NuGet & start querying in minutes
Crafted for clarity and speed, InstructSharp turns advanced AI workflows into everyday dev tasks 🎯👍.
Installation
dotnet add package InstructSharp
Or via Package Manager:
Install-Package InstructSharp
Supported Providers
- OpenAI ChatGPT (
ChatGPTClient
) - Anthropic Claude (
ClaudeClient
) - Google Gemini (
GeminiClient
) - X.AI Grok (
GrokClient
) - DeepSeek (
DeepSeekClient
) - Meta LLaMA (via DeepInfra) (
LLamaClient
)
Each client implements the same QueryAsync<T>
pattern and returns a LLMResponse<T>
.
Quick Start
Define your output schema
class QuestionAnswer { public string Question { get; set; } public string Answer { get; set; } }
Instantiate a client
// ChatGPT example var chat = new ChatGPTClient("YOUR_OPENAI_API_KEY");
Build a request
var req = new ChatGPTRequest { Model = ChatGPTModels.GPT41, Instruction = "Talk like a pirate.", Input = "Are semicolons optional in JavaScript?" };
Send and receive structured output
var res = await chat.QueryAsync<QuestionAnswer>(req); Console.WriteLine($"Q: {res.Result.Question}"); Console.WriteLine($"A: {res.Result.Answer}");
Plain‐text fallback
// For unstructured responses: var textRes = await chat.QueryAsync<string>(req); Console.WriteLine(textRes.Result);
Full Demo
using InstructSharp.Clients.ChatGPT;
using InstructSharp.Core;
using System.Text.Json;
// ...
var client = new ChatGPTClient("sk-...");
var request = new ChatGPTRequest {
Model = ChatGPTModels.GPT41,
Instruction = "Talk like a pirate.",
Input = "What is 2 + 2?"
};
var response = await client.QueryAsync<QuestionAnswer>(request);
Console.WriteLine(JsonSerializer.Serialize(response.Result));
// → { "Question":"What is 2 + 2?","Answer":"Arr, 'tis four, matey!" }
Repeat the same steps for any other provider:
var claude = new ClaudeClient("YOUR_CLAUDE_KEY");
var gemini = new GeminiClient("YOUR_GOOGLE_KEY", GeminiModels.Flash25);
// …and so on…
Advanced
- Custom types: any POCO can be used as
T
. - Temperature, max_tokens, etc. available via each provider’s request class.
- Error handling: exceptions thrown on non-2xx responses. Inspect
response.Usage
andresponse.AdditionalData
for extra info.
Contributing
- Fork the repo
- Implement your feature / fix
- Send a PR
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. 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. |
-
net8.0
- Newtonsoft.Json (>= 13.0.3)
- NJsonSchema (>= 11.3.2)
- NJsonSchema.NewtonsoftJson (>= 11.3.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.