Function set_key

Source
pub fn set_key(value: String)
Expand description

Sets the key for all OpenAI API functions.

ยงExamples

Use environment variable OPENAI_KEY defined from .env file:

use openai::set_key;
use dotenvy::dotenv;
use std::env;

dotenv().ok();
set_key(env::var("OPENAI_KEY").unwrap());