openai-api-stream-rs
A Rust crate that provides a simple function for interacting with the OpenAI API and performing language-based tasks. This crate focuses on streaming responses from the API, enabling real-time processing of large amounts of data.
Features
- Stream-based API: The crate supports streaming responses from the OpenAI API, allowing you to process data in real-time as it becomes available.
- GptStream: The
GptStream
struct provides a convenient interface for interacting with the OpenAI chat completions endpoint. - JSON Parsing: The crate includes robust JSON parsing capabilities for handling API responses.
- Configuration Options: You can easily configure various parameters such as model selection, temperature, top-p, and more.
Usage
To use this crate, simply create an instance of the OpenAIStream
struct, passing your API key as a parameter. Then, call the gpt_stream
method with your desired input and await the response. The returned GptStream
object allows you to asynchronously iterate over the streaming API response.
Example:
[]
= "0.1.0"
= { = "1.12.0", = ["full"] }
= "0.3.19"
use OpenAIStream;
use StreamExt;
async
Note: Replace "your_api_key" with your actual OpenAI API key.
For more details and advanced configuration options, please refer to the crate documentation.
Note: This crate is still in development and may be subject to changes and updates.