Skip to main content

floopy/
lib.rs

1//! Official Floopy AI Gateway SDK for Rust.
2//!
3//! `floopy-sdk` wraps the official [`async_openai`] crate and points it at
4//! the Floopy gateway, so `chat`/`embeddings`/`models` stay a 1:1 drop-in
5//! replacement, and adds typed Floopy-only resources (feedback, decisions,
6//! experiments, constraints, decision export, evaluations, routing dry-run,
7//! sessions) on top. It mirrors the Node, Python and Go SDKs so behaviour
8//! stays in lockstep across languages.
9//!
10//! ```no_run
11//! use floopy::Floopy;
12//! use async_openai::types::chat::{
13//!     ChatCompletionRequestUserMessageArgs, CreateChatCompletionRequestArgs,
14//! };
15//!
16//! # async fn run() -> Result<(), Box<dyn std::error::Error>> {
17//! let client = Floopy::new(std::env::var("FLOOPY_API_KEY")?)?;
18//!
19//! let request = CreateChatCompletionRequestArgs::default()
20//!     .model("gpt-4o")
21//!     .messages(vec![ChatCompletionRequestUserMessageArgs::default()
22//!         .content("Hello from Floopy!")
23//!         .build()?
24//!         .into()])
25//!     .build()?;
26//!
27//! let response = client.openai().chat().create(request).await?;
28//! println!("{:?}", response.choices[0].message.content);
29//! # Ok(())
30//! # }
31//! ```
32//!
33//! Every Floopy-only call returns [`Result<T, Error>`](Error). Errors from
34//! the OpenAI-compatible surface come from [`async_openai`] instead.
35
36#![deny(missing_docs)]
37#![cfg_attr(docsrs, feature(doc_cfg))]
38
39mod client;
40mod constants;
41mod error;
42mod headers;
43mod http;
44mod openai_delegate;
45mod options;
46pub mod resources;
47pub mod types;
48
49pub use client::{Floopy, FloopyBuilder};
50pub use constants::{CONFIRM_EXPERIMENTS, DEFAULT_BASE_URL, DEFAULT_MAX_RETRIES, DEFAULT_TIMEOUT};
51pub use error::{Error, ErrorDetails, Result};
52pub use options::{CacheOptions, FloopyOptions, RequestOptions};
53
54// Re-export the wrapped OpenAI crate so consumers can build chat/embedding
55// requests without a separate `async-openai` dependency declaration.
56pub use async_openai;