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
| Variable | Description | Default |
|---|---|---|
TYPESAFE_API_KEY | API key (required) | — |
TYPESAFE_BASE_URL | API root URL | https://api.typesafe.ai |
TYPESAFE_DEFAULT_MODEL | Default model name | jev-latest |
TYPESAFE_LOG_LEVEL | Log verbosity | warn |
§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§
Constants§
- VERSION
- Crate version.