| Crates.io | openai-chat |
| lib.rs | openai-chat |
| version | 0.1.1 |
| created_at | 2023-03-07 07:01:05.05578+00 |
| updated_at | 2023-03-16 03:36:55.401465+00 |
| description | chatgpt api |
| homepage | |
| repository | https://github.com/dobefore/chatgpt-api-rs |
| max_upload_size | |
| id | 803357 |
| size | 58,877 |
wrapper for official openai api for chatgpt in Rust.
Currently support models text-davinci-003 and gpt-3.5-turbo.
Todo: [ ] context dialog
use model text-davinci-003
use std::env;
use chatgpt_api::completions;
#[actix_rt::main]
async fn main() {
let api_key = env::var("OPEN_AI_API_KEY").expect("OPEN_AI_API_KEY must be set");
let _ret=completions("how are you", &api_key).await.unwrap();
}
and gpt-3.5-turbo
use std::env;
use chatgpt_api::chat_completions;
let api_key = env::var("OPEN_AI_API_KEY").expect("OPEN_AI_API_KEY must be set");
async fn gpt35_turbo() {
let api_key = env::var("OPEN_AI_API_KEY").expect("OPEN_AI_API_KEY must be set");
let _ret=chat_completions("how are you", &api_key).await;
}