Skip to main content
The Edgee Rust SDK provides multiple ways to instantiate a client. Rust offers both idiomatic named constructors and a unified constructor for consistency with other SDKs.

Overview

The Rust SDK provides several constructor methods:
  • Edgee::from_env() - Reads from environment variables (idiomatic Rust)
  • Edgee::with_api_key() - Creates client with just an API key (convenience)
  • Edgee::new() - Creates client with full EdgeeConfig (type-safe)
The simplest and most secure approach is to use environment variables. The SDK will automatically read EDGEE_API_KEY and optionally EDGEE_BASE_URL.

Method 2: API Key Only (Quick Start)

For quick testing or simple scripts, use with_api_key():
Note: This method uses the default base URL (https://edgee.io). To use a custom base URL, use Method 3.

Method 3: Configuration Object (Type-Safe)

For full control and type safety, use EdgeeConfig with the builder pattern:
Important: The api_key is required and must be provided either via constructor argument or EDGEE_API_KEY environment variable. If neither is provided, an Error::MissingApiKey will be returned.

Error Handling

The SDK uses Rust’s Result<T, E> type for explicit error handling:

Using ? Operator

Custom Error Handling

Complete Examples

Example 1: Production Setup

Example 2: Multi-Environment Setup

Troubleshooting

”MissingApiKey” Error

Problem: The SDK can’t find your API key. Solutions:
  1. Set the environment variable:
  2. Use with_api_key():
  3. Use EdgeeConfig:

Custom Base URL Not Working

Problem: Your custom base URL isn’t being used. Check:
  1. Verify the base URL in your configuration
  2. Check if environment variable EDGEE_BASE_URL is overriding it
  3. Ensure you’re using the correct configuration method