Description: I added an example of how to reference the OpenAI API
Organization ID, because I couldn't find it before. In the example, it
is mentioned how to achieve this using environment variables as well as
parameters for the OpenAI()-class
Issue: -
Dependencies: -
Twitter @schop-rob
"The above cell assumes that your OpenAI API key is set in your environment variables. If you would rather manually specify your API key and/or organization ID, use the following code:\n",
"# get a token: https://platform.openai.com/account/api-keys\n",
"\n",
@ -38,7 +30,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 2,
"id": "5472a7cd-af26-48ca-ae9b-5f6ae73c74d2",
"metadata": {
"tags": []
@ -50,9 +42,24 @@
"os.environ[\"OPENAI_API_KEY\"] = OPENAI_API_KEY"
]
},
{
"cell_type": "markdown",
"id": "129a3275",
"metadata": {},
"source": [
"Should you need to specify your organization ID, you can use the following cell. However, it is not required if you are only part of a single organization or intend to use your default organization. You can check your default organization [here](https://platform.openai.com/account/api-keys).\n",
"\n",
"To specify your organization, you can use this:\n",
"Remove the openai_organization parameter should it not apply to you."
]
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 6,
"id": "a641dbd9",
"metadata": {
"tags": []
@ -105,7 +124,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 7,
"id": "9f844993",
"metadata": {
"tags": []
@ -114,10 +133,10 @@
{
"data": {
"text/plain": [
"' Justin Bieber was born in 1994, so we are looking for the Super Bowl winner from that year. The Super Bowl in 1994 was Super Bowl XXVIII, and the winner was the Dallas Cowboys.'"
"' Justin Bieber was born in 1994, so the NFL team that won the Super Bowl in 1994 was the Dallas Cowboys.'"