ChatGPT Rust Library
A Rust library for interacting with OpenAI's ChatGPT API. This library simplifies the process of making requests to the ChatGPT API and parsing responses.
Features
- Easy to use interface for interacting with the ChatGPT API
- Strongly typed structures for request parameters and response data
- Support for serialization and deserialization using Serde
Installation
Add the following line to your 'Cargo.toml' file under the '[dependencies]' section:
= "0.1.0"
Then, run cargo build to download and compile the dependencies.
Usage
First, import the necessary components:
use ;
Next, create a new client with your API key:
let api_key = "your_api_key_here";
let base_url = "https://api.openai.com";
let client = new;
To send a chat message, create a ChatInput structure and call the chat method:
let chat_input = ChatInput ;
let response = client.chat.await.unwrap;
The response will be a 'ChatResponse' structure containing the API response data.
Documentation
For more details about the request parameters and response structure, refer to the OpenAI API documentation.
License
This project is licensed under the Apache License 2.0. See the LICENSE file for details.