Skip to main content

Crate floopy

Crate floopy 

Source
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 Floopy client (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§

CacheOptions
Cache controls. Maps to the Floopy-Cache-* headers. A None field is omitted (the gateway default applies).
ErrorDetails
Structured detail attached to every gateway-originated Error. It is always boxed inside the Error variants to keep the error type small.
Floopy
The Floopy gateway client.
FloopyBuilder
Builder for Floopy. Created via Floopy::builder.
FloopyOptions
Gateway behaviour toggles, mapped to Floopy-* headers and forwarded to every request (both OpenAI-compatible and Floopy-only). Empty / None fields are omitted.
RequestOptions
Per-call overrides, merged on top of the client defaults. Construct with RequestOptions::new and the builder-style setters.

Enums§

Error
Every error returned by a Floopy-only resource.

Constants§

CONFIRM_EXPERIMENTS
The X-Floopy-Confirm value 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_url for 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.