Skip to content
Rasmus Wulff Jensen edited this page Dec 26, 2025 · 3 revisions

NuGet README

Features

  • AgentFactory (XAIAgentFactory)
  • AIToolsFactory integration (tools in AgentOptions.Tools)
  • OpenAI-style reasoning settings and ClientType (ChatClient or ResponsesApi)

Package

dotnet add package AgentFrameworkToolkit.XAI

Quick start

XAIAgentFactory agentFactory = new("<apiKey>");
XAIAgent agent = agentFactory.CreateAgent(new AgentOptions
{
    Model = "grok-4-1-fast-reasoning",
    ReasoningEffort = OpenAIReasoningEffort.Low,
    Instructions = "You are a nice AI"
});

AgentRunResponse response = await agent.RunAsync("Hello World");
Console.WriteLine(response);

Connection options

  • ApiKey (required)
  • Endpoint (optional, defaults to https://api.x.ai/v1)
  • NetworkTimeout
  • DefaultClientType
  • AdditionalOpenAIClientOptions

Dependency injection

builder.Services.AddXAIAgentFactory("<apiKey>");
builder.Services.AddXAIAgentFactory(new XAIConnection
{
    ApiKey = "<apiKey>"
});

Notes

Clone this wiki locally