Skip to content

Writer

Nuget package dotnet License: MIT Discord

Features 🔥

  • Fully generated C# SDK based on official Writer OpenAPI specification using AutoSDK
  • Same day update to support new features
  • Updated and supported automatically if there are no breaking changes
  • All modern .NET features - nullability, trimming, NativeAOT, etc.
  • Support .Net Framework/.Net Standard 2.0

Usage

1
2
3
using Writer;

using var client = new WriterClient(apiKey);

Generate

Basic example showing how to create a client and make a request.

1
using var client = new WriterClient(apiKey);

Chat Client Get Response

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
using var client = new WriterClient(apiKey);
Meai.IChatClient chatClient = client;

// Use the MEAI IChatClient interface for chat completions.
var response = await chatClient.GetResponseAsync(
    messages: [new Meai.ChatMessage(Meai.ChatRole.User, "Generate 5 random words.")],
    new Meai.ChatOptions
    {
        ModelId = "palmyra-x-004",
    });

Console.WriteLine(response.Text);

Chat Client Streaming

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
using var client = new WriterClient(apiKey);
Meai.IChatClient chatClient = client;

// Stream chat responses using the MEAI IChatClient interface.
var enumerable = chatClient.GetStreamingResponseAsync(
    messages: [new Meai.ChatMessage(Meai.ChatRole.User, "Generate 5 random words.")],
    new Meai.ChatOptions
    {
        ModelId = "palmyra-x-004",
    });

var deltas = new List<string>();
await foreach (var update in enumerable)
{
    Console.Write(update.Text);
    deltas.Add(update.Text ?? string.Empty);
}

Chat Client Get Service Metadata

1
2
3
4
5
using var client = new WriterClient("test-api-key");
Meai.IChatClient chatClient = client;

// Retrieve metadata about the chat provider.
var metadata = Meai.ChatClientExtensions.GetService<Meai.ChatClientMetadata>(chatClient);

Chat Client Streaming Tool Calling

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using var client = new WriterClient(apiKey);
Meai.IChatClient chatClient = client;

// Stream chat responses with tool calling using the MEAI IChatClient interface.
// Define a simple tool that returns the current weather.
var tool = Meai.AIFunctionFactory.Create(
    (string location) => $"The weather in {location} is sunny, 72°F.",
    "get_weather",
    "Gets the current weather for a location.");

var enumerable = chatClient.GetStreamingResponseAsync(
    messages: [new Meai.ChatMessage(Meai.ChatRole.User, "What's the weather in San Francisco?")],
    new Meai.ChatOptions
    {
        ModelId = "palmyra-x-004",
        Tools = [tool],
    });

var hasContent = false;
Meai.ChatFinishReason? finishReason = null;
await foreach (var update in enumerable)
{
    if (update.Text is { Length: > 0 })
    {
        Console.Write(update.Text);
        hasContent = true;
    }

    if (update.FinishReason is not null)
    {
        finishReason = update.FinishReason;
    }
}

// The model should either respond with tool calls or text content.

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.

Support

Priority place for bugs: https://github.com/tryAGI/Writer/issues
Priority place for ideas and general questions: https://github.com/tryAGI/Writer/discussions
Discord: https://discord.gg/Ca2xhfBf3v

Acknowledgments

JetBrains logo

This project is supported by JetBrains through the Open Source Support Program.