Gh_models - Github models for Rust
โ Rust ๐ 2025-10-04 ๐ค surdeus ๐๏ธ 6gh_models is a Rust crate providing a simple interface to the GitHub Models API. It enables calling GitHub-hosted AI models from Rust, similar to OpenAIโs Python client.
Installation
Add to Cargo.toml:
gh_models = "0.1.0"
Authentication
Set a GitHub personal access token with model access as an environment variable:
export GITHUB_TOKEN=your_token_here
How to generate a token:
GitHub PAT documentation
Make sure when making a token you set the Models account permission:
Usage Example
use gh_models::{GHModels, types::ChatMessage};
use std::env;
#[tokio::main]
async fn main() {
let token = env::var("GITHUB_TOKEN").expect("GITHUB_TOKEN not set");
let client = GHModels::new(token);
let messages = vec![
ChatMessage { role: "system".into(), content: "You are a helpful assistant.".into() },
ChatMessage { role: "user".into(), content: "What is the capital of France?".into() },
];
let response = client.chat_completion("openai/gpt-4o", messages, 1.0, 4096, 1.0).await.unwrap();
println!("{}", response.choices[0].message.content);
}
Links
- Crate: https://crates.io/crates/gh_models
- Repository: https://github.com/pjdur/gh_models
- Documentation: https://docs.rs/gh_models
1 post - 1 participant
๐ท๏ธ Rust_feed
