Buble Rust SDK
Official Rust SDK for Buble, built for the Buble public API.
Use this SDK from server-side Rust applications to discover media models, upload source media, create asynchronous image and video generation tasks, run preconfigured Buble app workflows, and call chat models through OpenAI, Anthropic Messages, and Gemini-compatible API formats.
Keep API keys on the server. Do not expose BUBLE_API_KEY in browser, mobile, or other client-side code.
Installation
After publication to crates.io:
Or add it to Cargo.toml:
[]
= "0.1.0"
The crate requires Rust 1.88+ and uses async Rust with reqwest and Rustls TLS.
Quick Start
Set your API key:
The generation examples below create real Buble generation tasks and may consume credits.
use ;
async
The client reads BUBLE_API_KEY and BUBLE_BASE_URL from the environment when omitted.
Configuration
use Duration;
let client = builder
.api_key
.base_url
.timeout
.build?;
You may also pass an externally configured reqwest::Client:
let http = builder.build?;
let client = builder
.api_key
.http_client
.build?;
Discover Media Models
let models = client.media_models.list.await?;
for model in models.data
Use media model discovery as the source of truth for model keys, modes, required inputs, and public parameters. New Buble models can become available without an SDK release.
Upload Files
let uploaded = client
.files
.upload
.await?;
let task = client
.generations
.create
.await?;
Uploads support local paths and byte buffers. If model and mode are provided, Buble validates the upload against that model mode.
Video Generation
use Duration;
let task = client
.generations
.create
.await?;
let result = client
.generations
.wait
.await?;
Generation request bodies use Buble's flat public API shape. Put model-specific controls in param(...); the SDK serializes those controls at the JSON request root.
Do not send internal Buble fields such as input, options, scene, sub_mode_id, provider, mediaType, or media_type.
Apps
let app = client.apps.retrieve.await?;
println!;
let mut body = new;
body.insert;
let task = client
.apps
.generations
.create
.await?;
let result = client
.apps
.generations
.wait
.await?;
Apps are preconfigured workflows. Only send parameter names returned by client.apps().list(...) or client.apps().retrieve(...).
Chat
OpenAI-Compatible
let completion = client
.chat
.completions
.create
.await?;
Streaming
use StreamExt;
let mut stream = client
.chat
.completions
.stream_text
.await?;
while let Some = stream.next.await
Anthropic-Compatible
let message = client
.chat
.messages
.create
.await?;
Gemini-Compatible
let response = client
.chat
.gemini
.generate_content
.await?;
Gemini streaming uses stream_generate_content, not stream: true on generate_content.
Chat methods preserve protocol-native response shapes as serde_json::Value.
Error Handling
match client.generations.retrieve.await
match client.generations.wait.await
Development
RUSTDOCFLAGS="-D warnings"
Live smoke test:
BUBLE_API_KEY=sk_...
The live smoke test calls discovery and chat endpoints only and does not create billable generation tasks.
Publishing Checklist
crates.io package identity:
- Crate name:
buble - Library name:
buble - License: MIT
- Homepage:
https://buble.ai/ - Documentation:
https://docs.rs/buble
Local verification:
RUSTDOCFLAGS="-D warnings"
Publish:
crates.io versions are immutable. After 0.1.0 is published, fixes must use a new version such as 0.1.1. docs.rs builds package documentation automatically after crates.io publication.