File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,8 @@ $ export OPENAI_API_KEY=sk-xxxxxxx
20
20
21
21
### Create client
22
22
``` rust
23
- let client = OpenAIClient :: new (env :: var (" OPENAI_API_KEY" ). unwrap (). to_string ());
23
+ let api_key = env :: var (" OPENAI_API_KEY" ). unwrap (). to_string ();
24
+ let client = OpenAIClient :: builder (). with_api_key (api_key ). build ()? ;
24
25
```
25
26
26
27
### Create request
@@ -57,7 +58,8 @@ use std::env;
57
58
58
59
#[tokio:: main]
59
60
async fn main () -> Result <(), Box <dyn std :: error :: Error >> {
60
- let client = OpenAIClient :: new (env :: var (" OPENAI_API_KEY" ). unwrap (). to_string ());
61
+ let api_key = env :: var (" OPENAI_API_KEY" ). unwrap (). to_string ();
62
+ let client = OpenAIClient :: builder (). with_api_key (api_key ). build ()? ;
61
63
62
64
let req = ChatCompletionRequest :: new (
63
65
GPT4_O . to_string (),
You can’t perform that action at this time.
0 commit comments