Quickstart
Register the provider and evaluate your first flag.
Every quickstart follows the same three steps:
- Build a
TrustyGorillaConfigfrom your API key. - Register a
TrustyGorillaProviderwith OpenFeature. - Evaluate a flag through the OpenFeature client.
Pass a targeting key (usually a stable user ID) when evaluating so gradual rollouts and segment targeting resolve consistently for each user.
import { OpenFeature } from '@openfeature/server-sdk';
import { TrustyGorillaProvider, TrustyGorillaConfig } from '@trustygorilla/js-sdk';
const config = new TrustyGorillaConfig({ apiKey: process.env.TG_API_KEY! });
// Registers the provider and waits until the first flag fetch completes.
await OpenFeature.setProviderAndWait(new TrustyGorillaProvider(config));
const client = OpenFeature.getClient();
const darkMode = await client.getBooleanValue('dark_mode', false, {
targetingKey: 'user-123',
});
console.log(darkMode); // true | falseimport os
from openfeature import api
from openfeature.evaluation_context import EvaluationContext
from trustygorilla_sdk import TrustyGorillaConfig, TrustyGorillaProvider
config = TrustyGorillaConfig(api_key=os.environ["TG_API_KEY"])
api.set_provider(TrustyGorillaProvider(config))
client = api.get_client()
dark_mode = client.get_boolean_value(
"dark_mode",
False,
EvaluationContext(targeting_key="user-123"),
)
print(dark_mode) # True | Falsepackage main
import (
"context"
"fmt"
"os"
"github.com/open-feature/go-sdk/openfeature"
"github.com/trustygorilla/go-sdk"
)
func main() {
cfg, err := trustygorilla.NewTrustyGorillaConfig(os.Getenv("TG_API_KEY"))
if err != nil {
panic(err)
}
provider := trustygorilla.NewTrustyGorillaProvider(cfg)
openfeature.SetProvider(provider)
client := openfeature.NewClient("my-app")
darkMode, _ := client.BooleanValue(
context.Background(),
"dark_mode",
false,
openfeature.NewEvaluationContext("user-123", nil),
)
fmt.Println(darkMode) // true | false
}import com.trustygorilla.sdk.TrustyGorillaConfig;
import com.trustygorilla.sdk.TrustyGorillaProvider;
import dev.openfeature.sdk.Client;
import dev.openfeature.sdk.MutableContext;
import dev.openfeature.sdk.OpenFeatureAPI;
TrustyGorillaConfig config = TrustyGorillaConfig.builder()
.apiKey(System.getenv("TG_API_KEY"))
.build();
OpenFeatureAPI openfeature = OpenFeatureAPI.getInstance();
openfeature.setProviderAndWait(new TrustyGorillaProvider(config));
Client client = openfeature.getClient();
boolean darkMode = client.getBooleanValue(
"dark_mode",
false,
new MutableContext("user-123"));
System.out.println(darkMode); // true | falseimport com.trustygorilla.sdk.TrustyGorillaConfig
import com.trustygorilla.sdk.TrustyGorillaProvider
import dev.openfeature.sdk.ImmutableContext
import dev.openfeature.sdk.OpenFeatureAPI
val config = TrustyGorillaConfig(apiKey = System.getenv("TG_API_KEY"))
val api = OpenFeatureAPI.getInstance()
api.setProviderAndWait(TrustyGorillaProvider(config))
val client = api.client
val darkMode = client.getBooleanValue(
"dark_mode",
false,
ImmutableContext(targetingKey = "user-123"),
)
println(darkMode) // true | falseusing OpenFeature;
using OpenFeature.Model;
using TrustyGorilla.SDK;
var config = new TrustyGorillaConfig(ApiKey: Environment.GetEnvironmentVariable("TG_API_KEY")!);
await Api.Instance.SetProviderAsync(new TrustyGorillaProvider(config));
var client = Api.Instance.GetClient();
var context = EvaluationContext.Builder().SetTargetingKey("user-123").Build();
var darkMode = await client.GetBooleanValueAsync("dark_mode", false, context);
Console.WriteLine(darkMode); // True | False<?php
use OpenFeature\OpenFeatureAPI;
use OpenFeature\implementation\flags\EvaluationContext;
use TrustyGorilla\SDK\TrustyGorillaConfig;
use TrustyGorilla\SDK\TrustyGorillaProvider;
$config = new TrustyGorillaConfig(getenv('TG_API_KEY'));
$api = OpenFeatureAPI::getInstance();
$api->setProvider(new TrustyGorillaProvider($config));
$client = $api->getClient();
$darkMode = $client->getBooleanValue(
'dark_mode',
false,
new EvaluationContext('user-123'),
);
var_dump($darkMode); // bool(true) | bool(false)require "trustygorilla_sdk"
require "openfeature/sdk"
config = TrustyGorillaSDK::Config.new(api_key: ENV["TG_API_KEY"])
provider = TrustyGorillaSDK::Provider.new(config)
OpenFeature::SDK.configure { |c| c.set_provider(provider) }
client = OpenFeature::SDK.build_client
dark_mode = client.fetch_boolean_value(
flag_key: "dark_mode",
default_value: false,
evaluation_context: OpenFeature::SDK::EvaluationContext.new(targeting_key: "user-123"),
)
puts dark_mode # true | falseThe Swift SDK exposes the provider directly (it does not register with a global
OpenFeature API). Call initialize() once, then evaluate flags.
import TrustyGorillaSDK
let config = try TrustyGorillaConfig(apiKey: ProcessInfo.processInfo.environment["TG_API_KEY"]!)
let provider = TrustyGorillaProvider(config: config)
provider.initialize()
let details = try provider.getBooleanValue(
"dark_mode",
defaultValue: false,
targetingKey: "user-123"
)
print(details.value) // true | falseWhat happens next
The provider fetches flags immediately on registration, then refreshes every
pollIntervalSeconds (30 by default) in the background. Every evaluation reads
from the local cache, so there is no network latency on the hot path.
If a flag is missing or the provider is not ready, evaluations return the default value you passed — your app never fails because a flag can't be resolved.
Next: the full Reference covers configuration options, every evaluation method, and how targeting works.