BackOLLM

Rust Example

Rust example for integrating the OLLM API

Rust Example

Rust example for integrating the OLLM API

// OLLM API Example (Rust)
use reqwest::blocking::Client;
use serde_json::json;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let res: serde_json::Value = Client::new()
        .post("https://api.ollm.com/v1/chat/completions")
        .bearer_auth("your-api-key")
        .json(&json!({
            "model": "near/GLM-4.6",
            "messages": [{
                "role": "user",
                "content": "Why is the sky blue?"
            }]
        }))
        .send()?
        .json()?;

    println!("{}", res["choices"][0]["message"]["content"]);
    Ok(())
}

Community & further resources

Here you will find community Rust clients, CLIs or more advanced guides in the future.

Example community project (GitHub)