Crate agio

Source
Expand description

A Rust crate for configuring and using OpenAI in an agentic system.

This library provides a high-level interface to interact with OpenAI’s API, with particular focus on agent-based interactions that leverage tool calls (formerly known as function calls).

§Basic usage

use agio::{Agent, AgentBuilder, Config};

// Create a configuration
let config = Config::new()
    .with_api_key("your-api-key")
    .with_model("gpt-4o");

// Create an agent
let mut agent = AgentBuilder::new()
    .with_config(config)
    .with_system_prompt("You are a helpful assistant.")
    .build()?;

// Run the agent
let response = agent.run("Tell me about Rust programming.").await?;
println!("Response: {}", response);

Re-exports§

pub use crate::models::ToolDefinition;
pub use persistence::PersistenceStore;
pub use persistence::EntityId;
pub use persistence::ConversationMetadata;
pub use persistence::MemoryStore;
pub use persistence::postgres::PostgresStore;
pub use server::AgentManager;
pub use prelude::*;

Modules§

models
Data models for OpenAI API requests and responses.
persistence
Persistence layer for storing and retrieving agent data.
prelude
Commonly used types and traits
server
Server-side components for managing agents in a server environment.
websocket_client
WebSocket client for the OpenAI Realtime API (Beta).

Macros§

tool_fn
Creates a tool from a function.

Structs§

AgentState
The current state of the agent, including conversation history and token usage.
FunctionTool
A wrapper that turns a function into a tool.