Skip to main content

Crate openai_agents

Crate openai_agents 

Source
Expand description

OpenAI Agents SDK for Rust

A lightweight yet powerful framework for building multi-agent workflows.

§Quick Start

use openai_agents::{Agent, Runner};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let agent = Agent::builder("Assistant")
        .instructions("You are a helpful assistant.")
        .build();

    let result = Runner::run(&agent, "Hello!").await?;
    println!("{}", result.final_output());
    Ok(())
}

Re-exports§

pub use agent::Agent;
pub use agent::AgentBuilder;
pub use config::get_default_client;
pub use config::set_default_openai_client;
pub use config::set_default_openai_key;
pub use error::AgentError;
pub use error::Result;
pub use guardrail::GuardrailResult;
pub use guardrail::InputGuardrail;
pub use guardrail::OutputGuardrail;
pub use guardrail::ToolInputGuardrail;
pub use guardrail::ToolOutputGuardrail;
pub use handoff::Handoff;
pub use lifecycle::AgentHooks;
pub use lifecycle::RunHooks;
pub use models::CompletionRequest;
pub use models::CompletionResponse;
pub use models::ModelProvider;
pub use models::OpenAIChatCompletionsModel;
pub use models::OpenAIResponsesModel;
pub use result::RunResult;
pub use result::RunResultStreaming;
pub use runner::RunConfig;
pub use runner::Runner;
pub use session::InMemorySession;
pub use session::Session;
pub use session::SessionSettings;
pub use session::SqliteSession;
pub use stream_events::AgentUpdatedEvent;
pub use stream_events::RawResponseEvent;
pub use stream_events::RunItem;
pub use stream_events::RunItemEventName;
pub use stream_events::RunItemStreamEvent;
pub use stream_events::StreamEvent;
pub use streaming::StreamedRunResult;
pub use tool::FunctionTool;
pub use tool::Tool;

Modules§

agent
Agent definition and builder
config
Configuration management for the OpenAI Agents SDK
error
Error types for the OpenAI Agents SDK
guardrail
Guardrail system for input and output validation
handoff
lifecycle
Agent lifecycle hooks
models
Model provider abstraction and implementations
result
Result types for agent runs
runner
Runner for executing agents
session
Session management for conversation history
stream_events
streaming
tool
Tool trait and implementations
tracing_impl
Tracing implementation (placeholder)

Constants§

VERSION
The version of this crate

Attribute Macros§

function_tool
Procedural macro for creating function tools