Skip to content

Commit ac3b656

Browse files
committed
Update docs with newer approach to chat client
1 parent d933b1e commit ac3b656

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

src/AI/readme.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,16 @@ var messages = new Chat()
1414
{ "user", "What is 101*3?" },
1515
};
1616

17-
var grok = new GrokClient(Env.Get("XAI_API_KEY")!);
17+
IChatClient grok = new GrokClient(Env.Get("XAI_API_KEY")!)
18+
.GetChatClient("grok-3-mini")
19+
.AsIChatClient();
1820

1921
var options = new GrokChatOptions
2022
{
21-
ModelId = "grok-3-mini", // or "grok-3-mini-fast"
23+
ModelId = "grok-3-mini-fast", // can override the model on the client
2224
Temperature = 0.7f,
2325
ReasoningEffort = ReasoningEffort.High, // or ReasoningEffort.Low
24-
Search = GrokSearch.Auto, // or GrokSearch.On or GrokSearch.Off
26+
Search = GrokSearch.Auto, // or GrokSearch.On or GrokSearch.Off
2527
};
2628

2729
var response = await grok.GetResponseAsync(messages, options);
@@ -38,11 +40,12 @@ var messages = new Chat()
3840
{ "user", "What's Tesla stock worth today? Search X and the news for latest info." },
3941
};
4042

41-
var grok = new GrokClient(Env.Get("XAI_API_KEY")!);
43+
var grok = new GrokClient(Env.Get("XAI_API_KEY")!)
44+
.GetChatClient("grok-3")
45+
.AsIChatClient();
4246

4347
var options = new ChatOptions
4448
{
45-
ModelId = "grok-3",
4649
Tools = [new HostedWebSearchTool()]
4750
};
4851

@@ -83,6 +86,8 @@ The chat pipeline logging is added similar to other pipeline extensions:
8386

8487
```csharp
8588
IChatClient client = new GrokClient(Env.Get("XAI_API_KEY")!)
89+
.GetChatClient("grok-3-mini")
90+
.AsIChatClient()
8691
.AsBuilder()
8792
.UseOpenTelemetry()
8893
// other extensions...
@@ -95,7 +100,6 @@ IChatClient client = new GrokClient(Env.Get("XAI_API_KEY")!)
95100
.Build();
96101
```
97102

98-
99103
<!-- #content -->
100104
<!-- include https://github.com/devlooped/sponsors/raw/main/footer.md -->
101105
<!-- exclude -->

src/Weaving/readme.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ var messages = new Chat()
1111
{ "user", "What is 101*3?" },
1212
};
1313

14-
var grok = new GrokClient(Throw.IfNullOrEmpty(Env.Get("XAI_API_KEY")));
14+
IChatClient grok = new GrokClient(Throw.IfNullOrEmpty(Env.Get("XAI_API_KEY")))
15+
.GetChatClient("grok-3-mini") // or "grok-3-mini-fast"
16+
.AsIChatClient();
1517

1618
var options = new GrokChatOptions
1719
{
18-
ModelId = "grok-3-mini", // or "grok-3-mini-fast"
1920
ReasoningEffort = ReasoningEffort.High, // or ReasoningEffort.Low
20-
Search = GrokSearch.Auto, // or GrokSearch.On or GrokSearch.Off
21+
Search = GrokSearch.Auto, // or GrokSearch.On or GrokSearch.Off
2122
};
2223

2324
var response = await grok.GetResponseAsync(messages, options);

0 commit comments

Comments
 (0)