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
2020
2121### Create client
2222``` 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 ()? ;
2425```
2526
2627### Create request
@@ -57,7 +58,8 @@ use std::env;
5758
5859#[tokio:: main]
5960async 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 ()? ;
6163
6264 let req = ChatCompletionRequest :: new (
6365 GPT4_O . to_string (),
You can’t perform that action at this time.
0 commit comments