Function set_key

Source
pub fn set_key(value: String)
๐Ÿ‘ŽDeprecated since 1.0.0-alpha.16: use the Credentials struct instead
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());