openrouter_models/
openrouter_models.rs1use openai_api_rs::v1::api::OpenAIClient;
2use std::env;
3
4#[tokio::main]
5async fn main() -> Result<(), Box<dyn std::error::Error>> {
6 let api_key = env::var("OPENROUTER_API_KEY").unwrap().to_string();
7 let mut client = OpenAIClient::builder()
8 .with_endpoint("https://openrouter.ai/api/v1")
9 .with_api_key(api_key)
10 .build()?;
11
12 let result = client.list_models().await?;
13 let models = result.data;
14
15 for model in models {
16 println!("Model id: {:?}", model.id);
17 }
18
19 Ok(())
20}
21
22