Docs.rs
  • openai-rust-1.5.2
    • openai-rust 1.5.2
    • Permalink
    • Docs.rs crate page
    • MIT
    • Links
    • Repository
    • crates.io
    • Source
    • Owners
    • LevitatingBusinessMan
    • Dependencies
      • anyhow ^1.0.70 normal
      • bytes ^1.4.0 normal
      • futures-core ^0.3.29 normal
      • futures-util ^0.3.27 normal
      • lazy_static ^1.4.0 normal
      • reqwest ^0.11.14 normal
      • serde ^1.0.157 normal
      • serde_json ^1.0.94 normal
      • tokio ^1 dev
      • tokio-test ^0.4 dev
    • Versions
    • 55.03% of the crate is documented
  • Platform
    • i686-pc-windows-msvc
    • x86_64-apple-darwin
    • x86_64-pc-windows-msvc
    • x86_64-unknown-linux-gnu
  • Feature flags
  • docs.rs
    • About docs.rs
    • Badges
    • Builds
    • Metadata
    • Shorthand URLs
    • Download
    • Rustdoc JSON
    • Build queue
    • Privacy policy
  • Rust
    • Rust website
    • The Book
    • Standard Library API Reference
    • Rust by Example
    • The Cargo Guide
    • Clippy Documentation

Crate openai_rust

openai_rust1.5.2

  • All Items

Sections

  • openai-rust
    • Current features:
    • Example usage
    • Projects using openai-rust

Crate Items

  • Re-exports
  • Modules
  • Structs

Crates

  • openai_rust

Crate openai_rust

Source
Expand description

§openai-rust

Test Status Crates.io docs.rs

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 offical 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
let client = openai_rust::Client::new(&std::env::var("OPENAI_API_KEY").unwrap());
let args = openai_rust::chat::ChatArguments::new("gpt-3.5-turbo", vec![
    openai_rust::chat::Message {
        role: "user".to_owned(),
        content: "Hello GPT!".to_owned(),
    }
]);
let res = client.create_chat(args).await.unwrap();
println!("{}", res);

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.

Re-exports§

pub extern crate futures_util;

Modules§

chat
See https://platform.openai.com/docs/api-reference/chat. Use with Client::create_chat or Client::create_chat_stream.
completions
See https://platform.openai.com/docs/api-reference/completions. Use with Client::create_completion.
editsDeprecated
See https://platform.openai.com/docs/api-reference/edits. Use with Client::create_edit.
embeddings
See https://platform.openai.com/docs/api-reference/embeddings. Use with Client::create_embeddings.
images
See https://platform.openai.com/docs/api-reference/images. Use with Client::create_image.
models
See https://platform.openai.com/docs/api-reference/models. Use with Client::list_models.

Structs§

Client
This is the main interface to interact with the api.

Results

Settings
Help

Query parser error: "Unexpected - (did you mean ->?)".