tysm 0.1.0

A strongly-typed Rust client for OpenAI's ChatGPT API
Documentation

tysm

A strongly-typed Rust client for OpenAI's ChatGPT API that enforces type-safe responses using Structured Outputs.

Features

  • Type-safe API responses
  • Easy to use ChatClient interface
  • Support for system prompts and custom messages
  • Automatically get an OpenAI API Key from the environment

Usage

use tysm::ChatClient;

#[derive(Deserialize, JsonSchema)]
struct Name {
    first: String,
    last: String,
}

async fn typed_name() {
    let client = ChatClient::from_env("gpt-4o").unwrap();
    let name: Name = client.chat("Who was the first president?").await.unwrap();

    assert_eq!(name.first, "George");
    assert_eq!(name.last, "Washington");
}

License

This project is licensed under the MIT License.