openai-rust2
This is an unofficial library to interact with the Openai-API. The goal of this crate is to support the entire api while matching the official documentation as closely as possible.
Current features:
- Listing models
- Completions
- Chat
- Streaming Chat
- Edit
- Embeddings
- Images
- Audio
- Files
- Moderations
- Fine-tuning
Example usage
// Here we will use the chat completion endpoint connecting to openAI's default base URL
use openai_rust2 as openai_rust; // since this is a fork of openai_rust
let client = new;
let args = new;
let res = client.create_chat.await.unwrap;
println!;
Here another example connecting to a local LLM server (Ollama's base URL)
use openai_rust2 as openai_rust; // since this is a fork of openai_rust
let client = new_with_base_url;
You can run this code as an example with OPENAI_API_KEY=(your key) cargo run --example chat
.
Checkout the examples directory for more usage examples. You can find documentation on docs.rs.
Projects using openai-rust
- openai-cli: a CLI for interacting with GPT.
- gpt-cli-rust: Another CLI.
- electocracy: A digital voting system.
- awsgpt: Interact with the aws-cli via GPT.