Counting visitors…
Browse all docs
Start · 9Find your path through RunifoldLearn Runifold in 45 minutesUnderstand the complete Runifold platformYour first trustworthy runChoose the right execution APIChoose crates and Cargo featuresBuild common Runifold applicationsRunifold frequently asked questionsTroubleshoot Runifold applications
Execution kernel · 7Understand RunContextCoordinate external effects safelyBound work with budgets and cancellationHandle errors and retries safelyEvents, journals, and execution evidenceDesign capability-safe executionRecover safely from checkpoints
Models & providers · 7Route across models without duplicate outputChoose and configure a providerUse the provider-neutral model protocolBuild on the Provider Runtime contractUse OpenAI control-plane and Realtime APIsTest and benchmark provider adaptersSet up OpenAI, Anthropic, Gemini, and Ollama
Agents · 7Build and configure an AgentGive an Agent typed toolsAdd conversations and semantic memoryDelegate to child Agents safelyReturn structured Rust valuesStream without losing semanticsGround an Agent with retrieval
Durable workflows · 7Compose deterministic workflowsMake workflows durableOperate durable workflow workersCoordinate timers, signals, and durable waitsRun multi-tenant workflow infrastructureRun parallel branches and safe racesVersion and evolve durable workflows
Integrations · 7Connect through MCPChoose stores and persistence boundariesExpose durable work through MCP TasksBuild and evaluate retrieval pipelinesUse MCP Resources, Prompts, and SamplingCache MCP responses without crossing authorityDeploy Runifold in a Rust web service
Quality & operations · 10Test without the networkEvaluate quality and prevent regressionsObserve the complete run treeRun safely in browsers and at the edgeRead reliability claims preciselyRun reproducible evaluations in CIOperate Runifold with SLOsGovern Task retention and deletionArchive audit evidence to S3-compatible WORM storageManage compatibility and trusted releases
Docs/Tutorial
NEW TO RUNIFOLD?Build the complete mental model in 45 minutes
Tutorial

Your first trustworthy run

Create a Rust project, call a model, inspect the execution path, and fix the most common setup errors.

Practical guide·10 min

What you will build

You will create a small OpenAI-backed Agent, run one prompt, and understand the execution layers involved. The example is intentionally complete: you can paste it into a new project and run it without filling in omitted application code.

Prerequisites

  • Rust 1.88 or newer
  • an OpenAI API key available to the server process
  • a model your OpenAI project can access

Runifold is pre-alpha. Pin the crate version in applications that need reproducible builds, and review the changelog before upgrading.

Create the project

Create a binary crate and enable only the provider you need:

cargo new hello-runifold
cd hello-runifold
cargo add runifold@0.9.0
cargo add runifold-providers@0.9.0 --features openai
cargo add tokio --features macros,rt-multi-thread

Runifold 0.9 separates the runtime facade from concrete Provider adapters. runifold supplies Agents, Tools and workflows; runifold-providers compiles only the protocol adapters selected by its Features.

Set the credential in the process environment:

export OPENAI_API_KEY="your-api-key"

Long-lived provider credentials belong on the server. Browser and edge applications should call an application-owned gateway instead of embedding the key in WASM or JavaScript.

Run the Agent

Replace src/main.rs with:

use runifold::ProviderModelExt;
use runifold_providers::openai::OpenAiClient;
 
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let runtime = OpenAiClient::from_api_key(
        std::env::var("OPENAI_API_KEY")?
    )?
    .runtime("gpt-5")?;
 
    let answer = runtime
        .agent("assistant")
        .system("Answer precisely and expose uncertainty.")
        .prompt_text("Why is durable execution useful?")
        .await?;
 
    println!("{answer}");
    Ok(())
}

Run it:

cargo run

The exact answer varies by model, but the process should exit successfully and print one text response. If your account uses another model, change only the string passed to runtime.

Understand the path

The concise program still creates a complete execution path:

  1. OpenAiClient owns authentication and wire-protocol behavior.
  2. runtime("gpt-5") adds retry-safe routing and a circuit breaker.
  3. agent("assistant") creates the model-tool execution boundary.
  4. prompt_text creates an ergonomic root Run and returns visible text.

The convenience API does not implement a second, simplified engine. Later you can supply an explicit RunContext to the same Agent to add budgets, capabilities, deadlines, metadata, and a journal.

Troubleshooting

SymptomLikely causeFix
OPENAI_API_KEY is missingvariable was not exported to this shellexport it again in the terminal that runs Cargo
HTTP 401invalid or revoked credentialcreate a new key and update the environment
model not foundproject lacks access to gpt-5use a model available to your project
runifold_providers or openai is missingProvider crate or Feature was not addedrun cargo add runifold-providers@0.9.0 --features openai
request times outnetwork, provider, or application deadlineinspect the returned error before retrying

Do not blindly retry every failure. Runifold retries only errors the adapter marks as safe; an ambiguous failure may already have consumed tokens or produced an external effect.

For compilation, credentials, capability, streaming, or recovery failures, use the complete Troubleshooting guide.