Forge documentation
Rust

Rust quickstart

A source-correct, no-network first success in Rust.

Start with an operation that needs no model, network, identity seed, or wallet. This verifies the actual Rust message API before adding a provider or tools.

Prerequisites

Use the Rust toolchain pinned by the Forge source checkout. The workspace package version is 0.2.0; provider features and native/WASM compilation are separate profiles.

Use a source checkout

The paths below assume the Forge checkout is beside your application. Adjust the local path to your workspace. Registry publication is not inferred from the package name.

[dependencies]
forge-core = { path = "../forge/forge-rs/crates/forge-core" }

First success

Save this in your application's entry point after resolving forge-core.

use forge_core::message::{ModelMessage, Role};

fn main() {
    let message = ModelMessage::text(Role::User, "Hello, Forge");
    assert_eq!(message.text_content(), "Hello, Forge");
    println!("{}", message.text_content());
}

Expected output: Hello, Forge. This checks message construction and text extraction only; it does not call an LLM.

Add an agent

Rust ToolLoopAgent::new accepts configuration, an Arc<dyn LanguageModel>, a tool registry, and an approval handler. run is asynchronous and returns a result. Streaming agents and ordinary tool loops are different types. Import the agent library directly, or use forge_sdk::agent; the aggregate crate is named forge_sdk, not forge.

Verify the source

The example uses declarations from the message declarations. Package metadata comes from forge-rs/Cargo.toml.

Next

On this page