Skip to content

Commit 5d23f4f

Browse files
docs(client): document timeout option
1 parent b3db621 commit 5d23f4f

File tree

1 file changed

+44
-10
lines changed

1 file changed

+44
-10
lines changed

README.md

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ using System;
3535
using ArcadeDotnet;
3636
using ArcadeDotnet.Models.Tools;
3737

38-
// Configured using the ARCADE_API_KEY and ARCADE_BASE_URL environment variables
3938
ArcadeClient client = new();
4039

4140
ToolExecuteParams parameters = new() { ToolName = "Google.ListEmails" };
@@ -45,7 +44,7 @@ var executeToolResponse = await client.Tools.Execute(parameters);
4544
Console.WriteLine(executeToolResponse);
4645
```
4746

48-
## Client Configuration
47+
## Client configuration
4948

5049
Configure the client using environment variables:
5150

@@ -79,15 +78,18 @@ To temporarily use a modified client configuration, while reusing the same conne
7978

8079
```csharp
8180
using System;
82-
using ArcadeDotnet;
8381

84-
IArcadeClient clientWithOptions = client.WithOptions(options =>
85-
options with
86-
{
87-
BaseUrl = new("https://example.com"),
88-
Timeout = TimeSpan.FromSeconds(42),
89-
}
90-
);
82+
var chatResponse = await client
83+
.WithOptions(options =>
84+
options with
85+
{
86+
BaseUrl = new("https://example.com"),
87+
Timeout = TimeSpan.FromSeconds(42),
88+
}
89+
)
90+
.Chat.Completions.Create();
91+
92+
Console.WriteLine(chatResponse);
9193
```
9294

9395
Using a [`with` expression](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/with-expression) makes it easy to construct the modified options.
@@ -127,6 +129,38 @@ false
127129

128130
- `ArcadeException`: Base class for all exceptions.
129131

132+
## Network options
133+
134+
### Timeouts
135+
136+
Requests time out after 1 minute by default.
137+
138+
To set a custom timeout, configure the client using the `Timeout` option:
139+
140+
```csharp
141+
using System;
142+
using ArcadeDotnet;
143+
144+
ArcadeClient client = new() { Timeout = TimeSpan.FromSeconds(42) };
145+
```
146+
147+
Or configure a single method call using [`WithOptions`](#modifying-configuration):
148+
149+
```csharp
150+
using System;
151+
152+
var chatResponse = await client
153+
.WithOptions(options =>
154+
options with
155+
{
156+
Timeout = TimeSpan.FromSeconds(42)
157+
}
158+
)
159+
.Chat.Completions.Create();
160+
161+
Console.WriteLine(chatResponse);
162+
```
163+
130164
## Semantic versioning
131165

132166
This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:

0 commit comments

Comments
 (0)