Skip to content

Commit b48f420

Browse files
committed
Fix readme
1 parent 78c8fee commit b48f420

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff 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]
5960
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()?;
6163

6264
let req = ChatCompletionRequest::new(
6365
GPT4_O.to_string(),

0 commit comments

Comments
 (0)