OFFICIAL
Rust async-openai crate with Meridian
Point the async-openai client at Meridian's API base. Zero overhead, full streaming, native Rust async.
Cargo.toml
[dependencies]
async-openai = "0.23"
tokio = { version = "1", features = ["full"] }src/main.rs
use async_openai::{
config::OpenAIConfig,
Client,
types::CreateChatCompletionRequestArgs,
};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let config = OpenAIConfig::new()
.with_api_base("https://api.meridian.ai/v1")
.with_api_key("sk-meridian-xxxxxxxxxxxxxxxx");
let client = Client::with_config(config);
let request = CreateChatCompletionRequestArgs::default()
.model("meridian-4")
.messages(vec![
("system", "You are a helpful assistant.").into(),
("user", "Hello from Rust!").into(),
])
.build()?;
let response = client.chat().create(request).await?;
println!("{}", response.choices[0].message.content);
Ok(())
}Replace sk-meridian-xxxxxxxxxxxxxxxx with your key from the dashboard.