https://github.com/edgee-cloud/rust-sdk
The official Rust library for the Edgee AI Gateway
https://github.com/edgee-cloud/rust-sdk
ai anthropic edge edge-computing edgee gateway llm openai rust
Last synced: 2 months ago
JSON representation
The official Rust library for the Edgee AI Gateway
- Host: GitHub
- URL: https://github.com/edgee-cloud/rust-sdk
- Owner: edgee-cloud
- License: apache-2.0
- Created: 2024-04-26T12:26:01.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2026-01-12T13:55:31.000Z (3 months ago)
- Last Synced: 2026-01-12T19:34:31.021Z (3 months ago)
- Topics: ai, anthropic, edge, edge-computing, edgee, gateway, llm, openai, rust
- Language: Rust
- Homepage: https://www.edgee.cloud
- Size: 1.53 MB
- Stars: 79
- Watchers: 4
- Forks: 9
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
- Security: SECURITY.md
Awesome Lists containing this project
README
# Edgee Rust SDK
Modern, type-safe Rust SDK for the [Edgee AI Gateway](https://www.edgee.cloud).
[](https://crates.io/crates/edgee)
[](LICENSE)
[](https://www.rust-lang.org)
## Installation
Add this to your `Cargo.toml`:
```toml
[dependencies]
edgee = "2.0"
tokio = { version = "1", features = ["full"] }
```
## Quick Start
```rust
use edgee::Edgee;
#[tokio::main]
async fn main() -> Result<(), Box> {
let client = Edgee::from_env()?;
let response = client.send("gpt-4o", "What is the capital of France?").await?;
println!("{}", response.text().unwrap_or(""));
// "The capital of France is Paris."
Ok(())
}
```
## Send Method
The `send()` method makes non-streaming chat completion requests:
```rust
let response = client.send("gpt-4o", "Hello, world!").await?;
// Access response
println!("{}", response.text().unwrap_or("")); // Text content
println!("{:?}", response.finish_reason()); // Finish reason
if let Some(tool_calls) = response.tool_calls() { // Tool calls (if any)
println!("{:?}", tool_calls);
}
```
## Stream Method
The `stream()` method enables real-time streaming responses:
```rust
use tokio_stream::StreamExt;
let mut stream = client.stream("gpt-4o", "Tell me a story").await?;
while let Some(result) = stream.next().await {
match result {
Ok(chunk) => {
if let Some(text) = chunk.text() {
print!("{}", text);
}
if let Some(reason) = chunk.finish_reason() {
println!("\nFinished: {}", reason);
}
}
Err(e) => eprintln!("Error: {}", e),
}
}
```
## Features
- ✅ **Type-safe** - Leverages Rust's powerful type system
- ✅ **Async/await** - Built on tokio for efficient async operations
- ✅ **OpenAI-compatible** - Works with any model supported by Edgee
- ✅ **Streaming** - First-class support with `Stream` trait
- ✅ **Tool calling** - Full support for function calling
- ✅ **Zero-cost abstractions** - Efficient implementation with minimal overhead
## Documentation
For complete documentation, examples, and API reference, visit:
**👉 [Official Rust SDK Documentation](https://www.edgee.cloud/docs/sdk/rust)**
The documentation includes:
- [Configuration guide](https://www.edgee.cloud/docs/sdk/rust/configuration) - Multiple ways to configure the SDK
- [Send method](https://www.edgee.cloud/docs/sdk/rust/send) - Complete guide to non-streaming requests
- [Stream method](https://www.edgee.cloud/docs/sdk/rust/stream) - Streaming responses guide
- [Tools](https://www.edgee.cloud/docs/sdk/rust/tools) - Function calling guide
## Examples
Run the examples to see the SDK in action:
```bash
export EDGEE_API_KEY="your-api-key"
cargo run --example simple
cargo run --example streaming
cargo run --example tools
```
## License
Licensed under the Apache License, Version 2.0. See [LICENSE](LICENSE) for details.