This example demonstrates how to use LaunchDarkly's AI Config with the OpenAI provider.
- Python 3.10 or higher
- Poetry installed
- A LaunchDarkly account and SDK key
- An OpenAI API key
-
Create the following config in your LaunchDarkly project. You can use a different key by setting the environment variable in your
.env.- Create an AI Config with an OpenAI model (e.g.
gpt-4) and a system message. Default key:sample-completion-config.
- Create an AI Config with an OpenAI model (e.g.
-
Create a
.envfile in this directory with the following variables:LAUNCHDARKLY_SDK_KEY=your-launchdarkly-sdk-key LAUNCHDARKLY_AI_CONFIG_KEY=sample-completion-config OPENAI_API_KEY=your-openai-api-key -
Install the required dependencies:
poetry install
poetry run openai