Appearance
Getting Started: Rust
Use Rust with reqwest to call the BetterPrompt API.
rust
use reqwest::blocking::Client;
use serde_json::json;
use std::env;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let api_key = env::var("BETTERPROMPT_API_KEY").unwrap_or("YOUR_API_KEY".into());
let prompt_version_id = env::var("BP_PROMPT_VERSION_ID").unwrap_or("YOUR_PROMPT_VERSION_ID".into());
let client = Client::new();
let res = client
.post("https://api.betterprompt.me/v1/runs")
.bearer_auth(api_key)
.json(&json!({
"promptVersionId": prompt_version_id,
"inputs": {"textInputs": {"yourField": "value"}}
}))
.send()?;
let text = res.text()?;
println!("{}", text);
Ok(())
}