Skip to main content

openai_agents/
lib.rs

1//! OpenAI Agents SDK for Rust
2//!
3//! A lightweight yet powerful framework for building multi-agent workflows.
4//!
5//! # Quick Start
6//!
7//! ```rust,no_run
8//! use openai_agents::{Agent, Runner};
9//!
10//! #[tokio::main]
11//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
12//!     let agent = Agent::builder("Assistant")
13//!         .instructions("You are a helpful assistant.")
14//!         .build();
15//!
16//!     let result = Runner::run(&agent, "Hello!").await?;
17//!     println!("{}", result.final_output());
18//!     Ok(())
19//! }
20//! ```
21
22pub mod agent;
23pub mod config;
24pub mod error;
25pub mod guardrail;
26pub mod handoff;
27pub mod lifecycle;
28pub mod models;
29pub mod result;
30pub mod runner;
31pub mod session;
32pub mod stream_events;
33pub mod streaming;
34pub mod tool;
35pub mod tracing_impl;
36
37// Re-exports for convenience
38pub use agent::{Agent, AgentBuilder};
39pub use config::{get_default_client, set_default_openai_client, set_default_openai_key};
40pub use error::{AgentError, Result};
41pub use guardrail::{
42    GuardrailResult, InputGuardrail, OutputGuardrail, ToolInputGuardrail, ToolOutputGuardrail,
43};
44pub use handoff::Handoff;
45pub use lifecycle::{AgentHooks, RunHooks};
46pub use models::{
47    CompletionRequest, CompletionResponse, ModelProvider, OpenAIChatCompletionsModel,
48    OpenAIResponsesModel,
49};
50pub use result::{RunResult, RunResultStreaming};
51pub use runner::{RunConfig, Runner};
52pub use session::{InMemorySession, Session, SessionSettings};
53
54#[cfg(feature = "sqlite-session")]
55pub use session::SqliteSession;
56
57pub use stream_events::{
58    AgentUpdatedEvent, RawResponseEvent, RunItem, RunItemEventName, RunItemStreamEvent, StreamEvent,
59};
60pub use streaming::StreamedRunResult;
61pub use tool::{FunctionTool, Tool};
62
63// Re-export macros
64pub use openai_agents_macros::function_tool;
65
66/// The version of this crate
67pub const VERSION: &str = env!("CARGO_PKG_VERSION");