safi 0.1.0

Safi API Client for consuming chat, transcription, and translation APIs.
Documentation
use reqwest::Client;
use serde::{Deserialize, Serialize};
use std::error::Error;

#[derive(Serialize)]
struct ChatRequest {
    message: String,
}

#[derive(Deserialize)]
struct ChatResponse {
    response: String,
}

pub async fn chat(message: &str, api_key: &str) -> Result<String, Box<dyn Error>> {
    let client = Client::new();
    let request = ChatRequest {
        message: message.to_string(),
    };

    let response = client
        .post("https://safi.insolify.com/conversation")
        .json(&request)
        .bearer_auth(api_key)
        .send()
        .await?;

    let chat_response: ChatResponse = response.json().await?;
    Ok(chat_response.response)
}