mirror of
https://github.com/mii443/openai-api-rs.git
synced 2025-08-22 23:25:39 +00:00
Fix readme
This commit is contained in:
@ -20,7 +20,8 @@ $ export OPENAI_API_KEY=sk-xxxxxxx
|
|||||||
|
|
||||||
### Create client
|
### Create client
|
||||||
```rust
|
```rust
|
||||||
let client = OpenAIClient::new(env::var("OPENAI_API_KEY").unwrap().to_string());
|
let api_key = env::var("OPENAI_API_KEY").unwrap().to_string();
|
||||||
|
let client = OpenAIClient::builder().with_api_key(api_key).build()?;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Create request
|
### Create request
|
||||||
@ -57,7 +58,8 @@ use std::env;
|
|||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let client = OpenAIClient::new(env::var("OPENAI_API_KEY").unwrap().to_string());
|
let api_key = env::var("OPENAI_API_KEY").unwrap().to_string();
|
||||||
|
let client = OpenAIClient::builder().with_api_key(api_key).build()?;
|
||||||
|
|
||||||
let req = ChatCompletionRequest::new(
|
let req = ChatCompletionRequest::new(
|
||||||
GPT4_O.to_string(),
|
GPT4_O.to_string(),
|
||||||
|
Reference in New Issue
Block a user