Skip to main content

Crate typesafe_sdk

Crate typesafe_sdk 

Source
Expand description

§TypeSafe SDK for Rust

A community-maintained Rust client for the TypeSafe AI API.

TypeSafe answers typed questions about text or structured state. Create a client, describe the questions you want answered, and read the typed answers:

use typesafe_sdk::{Client, SystemOneRequest};
use serde_json::json;

let client = Client::from_env()?;

let response = client.system_one(
    SystemOneRequest::new("I was charged twice. Please fix this ASAP.")
        .question("category", typesafe_sdk::choice(
            "What is this ticket about?",
            [
                ("billing", Some(json!("Payments, invoicing, refunds"))),
                ("technical", Some(json!("Bugs, outages, integrations"))),
            ],
        )),
).await?;

for (name, answer) in response.choices() {
    println!("{name}: {}", answer.choice);
}

§Environment Variables

VariableDescriptionDefault
TYPESAFE_API_KEYAPI key (required)—
TYPESAFE_BASE_URLAPI root URLhttps://api.typesafe.ai
TYPESAFE_DEFAULT_MODELDefault model namejev-latest
TYPESAFE_LOG_LEVELLog verbositywarn

§Status

This is a community-maintained SDK, not an official TypeSafe AI product. Use it at your own risk. See the official SDKs for TypeSafe-maintained packages.

Re-exports§

pub use answers::Answer;
pub use answers::ChoiceAnswer;
pub use answers::NoulAnswer;
pub use answers::ScoreAnswer;
pub use answers::UnknownAnswer;
pub use client::Client;
pub use config::ClientBuilder;
pub use errors::ApiError;
pub use errors::ConnectionError;
pub use errors::Error;
pub use errors::ResponseError;
pub use errors::TimeoutError;
pub use questions::ChoiceQuestion;
pub use questions::NoulCriteria;
pub use questions::NoulQuestion;
pub use questions::Question;
pub use questions::ScoreQuestion;
pub use questions::choice;
pub use questions::noul;
pub use questions::noul_with_criteria;
pub use questions::score;
pub use retry::RetryPolicy;
pub use types::ModelMetadata;
pub use types::SystemOneRequest;
pub use types::SystemOneResponse;
pub use types::Usage;

Modules§

answers
client
config
errors
logging
questions
retry
types

Constants§

VERSION
Crate version.