A procedural macro that generates Rust code at compile-time using AI
github.com·7h·
Discuss: Hacker News
Rust Macros
Preview
Report Post

Caution

This Rust crate is potentially dangerous so there is a chance it will cause harm to you or your computer. Run at you own risk (ideally in a sandbox).

ai bindgen

This is a procedural macro that generates Rust code at compile-time using the OpenAI (or compatible) API. Simply add the dependency to your Cargo.toml and follow the example usage.

[dependencies]
ai-bindgen = { git = "https://github.com/germangb/ai-bindgen.git" }

Example usage

You must have a valid API token and define the following two variables in your environment, so the macro can connect to the OpenAI API, and select a model of your choosing:

export OPENAI_API_KEY="<your-api-token>"
export OPENAI_API_MODEL="gpt-5"

Note

By default the macro will send requests to `https://api.ope…

Similar Posts

Loading similar posts...