Expand description
Official Floopy AI Gateway SDK for Rust.
floopy-sdk wraps the official async_openai crate and points it at
the Floopy gateway, so chat/embeddings/models stay a 1:1 drop-in
replacement, and adds typed Floopy-only resources (feedback, decisions,
experiments, constraints, decision export, evaluations, routing dry-run,
sessions) on top. It mirrors the Node, Python and Go SDKs so behaviour
stays in lockstep across languages.
use floopy::Floopy;
use async_openai::types::chat::{
ChatCompletionRequestUserMessageArgs, CreateChatCompletionRequestArgs,
};
let client = Floopy::new(std::env::var("FLOOPY_API_KEY")?)?;
let request = CreateChatCompletionRequestArgs::default()
.model("gpt-4o")
.messages(vec![ChatCompletionRequestUserMessageArgs::default()
.content("Hello from Floopy!")
.build()?
.into()])
.build()?;
let response = client.openai().chat().create(request).await?;
println!("{:?}", response.choices[0].message.content);Every Floopy-only call returns Result<T, Error>. Errors from
the OpenAI-compatible surface come from async_openai instead.
Re-exports§
pub use async_openai;
Modules§
- resources
- Typed handles for every Floopy-only gateway resource. Obtain them from
the
Floopyclient (e.g.client.decisions()). - types
- Public, fully-typed data models for every Floopy-only resource. Wire field names are snake_case and map 1:1 to Rust field names (no rename attributes needed).
Structs§
- Cache
Options - Cache controls. Maps to the
Floopy-Cache-*headers. ANonefield is omitted (the gateway default applies). - Error
Details - Structured detail attached to every gateway-originated
Error. It is always boxed inside theErrorvariants to keep the error type small. - Floopy
- The Floopy gateway client.
- Floopy
Builder - Builder for
Floopy. Created viaFloopy::builder. - Floopy
Options - Gateway behaviour toggles, mapped to
Floopy-*headers and forwarded to every request (both OpenAI-compatible and Floopy-only). Empty /Nonefields are omitted. - Request
Options - Per-call overrides, merged on top of the client defaults. Construct with
RequestOptions::newand the builder-style setters.
Enums§
- Error
- Every error returned by a Floopy-only resource.
Constants§
- CONFIRM_
EXPERIMENTS - The
X-Floopy-Confirmvalue the gateway requires on experiment create/rollback (gateway control SEC-009). Injected automatically by the experiments resource. - DEFAULT_
BASE_ URL - The public Floopy gateway base URL. Override with
crate::FloopyBuilder::base_urlfor self-hosted gateways. - DEFAULT_
MAX_ RETRIES - Default retry budget for transient failures.
- DEFAULT_
TIMEOUT - Default per-request timeout when none is configured.
Type Aliases§
- Result
- Convenience alias for results returned by Floopy-only resources.