#chatgpt #openai #api-bindings


Blocking ChatGPT API Wrapper

3 releases

new 0.1.2 Apr 29, 2024
0.1.1 Jul 25, 2023
0.1.0 Mar 28, 2023

#2 in #chat-gpt

47 downloads per month
Used in hoard-rs

MIT license

201 lines


Fork of Async chatgpt_rs I needed a blocking variation of this without reqwest


Here is a simple usage of the API, getting completion for a single message. You can see more practical examples in the examples directory.

use chatgpt::prelude::*;

async fn main() -> Result<()> {
    // Getting the API key here
    let key = args().nth(1).unwrap();

    /// Creating a new ChatGPT client.
    /// Note that it requires an API key, and uses
    /// tokens from your OpenAI API account balance.
    let client = ChatGPT::new(key)?;

    /// Sending a message and getting the completion
    let response: CompletionResponse = client
        .send_message("Describe in five words the Rust programming language.")

    println!("Response: {}", response.message().content);



~567K SLoC