agixt_sdk/lib.rs
1//! # AGiXT Rust SDK
2//!
3//! This is the official Rust SDK for AGiXT, providing a type-safe way to interact with the AGiXT API.
4//! All endpoints use the /v1 API with ID-based parameters.
5//!
6//! ## Features
7//!
8//! - Full API coverage for AGiXT v1 endpoints
9//! - Async/await support with tokio
10//! - Type-safe request and response handling
11//! - Comprehensive error handling
12//! - ID-based resource management (agents, conversations, chains, prompts)
13//!
14//! ## Example
15//!
16//! ```rust,no_run
17//! use agixt_sdk::AGiXTSDK;
18//!
19//! #[tokio::main]
20//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
21//! // Create a new SDK instance
22//! let client = AGiXTSDK::new(
23//! Some("http://localhost:7437".to_string()),
24//! Some("your-api-key".to_string()),
25//! false,
26//! );
27//!
28//! // Get list of available providers
29//! let providers = client.get_providers().await?;
30//! println!("Available providers: {:?}", providers);
31//!
32//! // Create a new agent and get its ID
33//! let agent_result = client.add_agent("my_agent", None, None, None).await?;
34//! let agent_id = agent_result["id"].as_str().unwrap();
35//! println!("Created agent with ID: {}", agent_id);
36//!
37//! // Create a new conversation with the agent
38//! let conv_result = client.new_conversation(agent_id, "test_conversation", None).await?;
39//! let conversation_id = conv_result["id"].as_str().unwrap();
40//! println!("Created conversation with ID: {}", conversation_id);
41//!
42//! // Chat with the agent
43//! let response = client.chat(agent_id, "Hello!", conversation_id, None).await?;
44//! println!("Agent response: {}", response);
45//!
46//! Ok(())
47//! }
48//! ```
49//!
50//! ## Authentication
51//!
52//! ```rust,no_run
53//! use agixt_sdk::AGiXTSDK;
54//!
55//! #[tokio::main]
56//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
57//! let client = AGiXTSDK::new(None, None, false);
58//!
59//! // Register a new user
60//! let otp_uri = client.register_user(
61//! "user@example.com",
62//! "John",
63//! "Doe"
64//! ).await?;
65//! println!("Registration successful. OTP URI: {}", otp_uri);
66//!
67//! // Login with email and OTP
68//! if let Some(token) = client.login("user@example.com", "123456").await? {
69//! println!("Login successful! Token: {}", token);
70//! }
71//!
72//! Ok(())
73//! }
74//! ```
75//!
76//! ## ID-Based Resource Management
77//!
78//! The SDK uses ID-based parameters for all resource operations. Helper methods are provided
79//! to look up IDs by name:
80//!
81//! ```rust,no_run
82//! use agixt_sdk::AGiXTSDK;
83//!
84//! #[tokio::main]
85//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
86//! let client = AGiXTSDK::new(None, Some("your-token".to_string()), false);
87//!
88//! // Look up agent ID by name
89//! if let Some(agent_id) = client.get_agent_id_by_name("XT").await? {
90//! println!("Found agent with ID: {}", agent_id);
91//!
92//! // Use the ID for operations
93//! let config = client.get_agentconfig(&agent_id).await?;
94//! println!("Agent config: {:?}", config);
95//! }
96//!
97//! // Look up conversation ID by name
98//! if let Some(conv_id) = client.get_conversation_id_by_name("My Chat").await? {
99//! let history = client.get_conversation(&conv_id, None, None).await?;
100//! println!("Conversation history: {:?}", history);
101//! }
102//!
103//! // Look up chain ID by name
104//! if let Some(chain_id) = client.get_chain_id_by_name("Smart Instruct").await? {
105//! let chain_data = client.get_chain(&chain_id).await?;
106//! println!("Chain: {:?}", chain_data);
107//! }
108//!
109//! Ok(())
110//! }
111//! ```
112
113pub mod client;
114pub mod error;
115pub mod models;
116
117pub use client::AGiXTSDK;
118pub use error::{Error, Result};
119pub use models::{
120 Agent, Chain, ChainStep, ChatCompletions, ChatResponse, Choice, Company, ContentPart,
121 Conversation, Extension, ExtensionCommand, FileUrl, ImageUrl, Message, MessageContent,
122 Prompt, Provider, Tool, ToolFunction, Usage, User,
123};