We've built a simple console application that demonstrates how LaunchDarkly's Ruby AI SDK works.
Below, you'll find the build procedure. For more comprehensive instructions, you can visit your Quickstart page or the Ruby reference guide.
This demo requires Ruby 3.1 or higher.
This repository includes examples for OpenAI and Bedrock. Depending on your preferred provider, you may have to take some additional steps.
-
Install the required dependencies with
bundle installin the appropriate example directory. -
Create an AI Config using the key specified in the examples, or copy the key of an existing AI Config in your LaunchDarkly project that you want to use.
-
Update the default model (
replace-with-your-model) in the example file. -
Set the environment variable
LAUNCHDARKLY_SDK_KEYto your LaunchDarkly SDK key andLAUNCHDARKLY_AI_CONFIG_KEYto the AI Config key; otherwise, an AI Config ofsample-ai-configwill be assumed.export LAUNCHDARKLY_SDK_KEY="1234567890abcdef" export LAUNCHDARKLY_AI_CONFIG_KEY="sample-ai-config"
-
Set the environment variable
OPENAI_API_KEYto your OpenAI key.export OPENAI_API_KEY="0987654321fedcba"
-
Run the program
bundle exec ruby hello_openai.rb
-
Ensure the required AWS credentials can be auto-detected by the AWS client. In the provided example we use the following environment variables.
export AWS_ACCESS_KEY_ID="0987654321fedcba" export AWS_SECRET_ACCESS_KEY="0987654321fedcba" # or export AWS_PROFILE="aws-profile-name"
-
Run the program
bundle exec ruby hello_bedrock.rb