Overview
TheNewClient function accepts multiple input types:
nil- reads from environment variablesstring- API key string*Config- Configuration struct (type-safe)map[string]interface{}- Plain map (flexible)
Method 1: Environment Variables (Recommended for Production)
The simplest and most secure approach is to use environment variables. The SDK will automatically readEDGEE_API_KEY and optionally EDGEE_BASE_URL.
Method 2: String API Key (Quick Start)
For quick testing or simple scripts, pass the API key directly as a string:https://api.edgee.ai). To use a custom base URL, use Method 3.
Method 3: Configuration Struct (Type-Safe)
For better type safety and IDE support, use theConfig struct:
Configuration Priority
The SDK uses the following priority order when resolving configuration:- Constructor argument (if provided)
- Environment variable (if constructor argument is missing)
- Default value (for
base_urlonly, defaults tohttps://api.edgee.ai)
Complete Examples
Example 1: Production Setup
Example 2: Multi-Environment Setup
Troubleshooting
”EDGEE_API_KEY is not set” Error
Problem: The SDK can’t find your API key. Solutions:-
Set the environment variable:
-
Pass it directly:
-
Use Config struct:
Custom Base URL Not Working
Problem: Your custom base URL isn’t being used. Check:- Verify the base URL in your configuration
- Check if environment variable
EDGEE_BASE_URLis overriding it - Ensure you’re using the correct configuration method
Related Documentation
- Go SDK Overview - Complete SDK documentation
- API Reference - REST API documentation
- Quickstart Guide - Get started with Edgee