Skip to main content

run

Function run 

Source
pub async fn run(instructions: &str, input: &str) -> Result<String>
Available on crate features agents and sessions and runner only.
Expand description

High-level single-turn agent invocation.

Creates an agent with the given instructions, sends the input, and returns the text response. Uses provider_from_env to auto-detect the LLM provider.

This is the fastest way to get started with ADK — a single function call that handles provider selection, session creation, agent building, and execution.

§Arguments

  • instructions - System instructions for the agent
  • input - User input to send to the agent

§Returns

The agent’s text response as a String.

§Errors

Returns AdkError when no supported environment variable is set, or when agent execution fails.

§Example

use adk_rust::run;

let response = run("You are a helpful assistant.", "What is 2 + 2?").await?;
println!("{response}");