From 0973b2bd76b2ee15e71d660ac42689a7f92104ea Mon Sep 17 00:00:00 2001 From: Victor Dibia Date: Wed, 12 Feb 2025 10:05:22 -0800 Subject: [PATCH 1/2] update model clients docs --- .../components/model-clients.ipynb | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/python/packages/autogen-core/docs/src/user-guide/core-user-guide/components/model-clients.ipynb b/python/packages/autogen-core/docs/src/user-guide/core-user-guide/components/model-clients.ipynb index df6bb2d1ac77..404c478011e3 100644 --- a/python/packages/autogen-core/docs/src/user-guide/core-user-guide/components/model-clients.ipynb +++ b/python/packages/autogen-core/docs/src/user-guide/core-user-guide/components/model-clients.ipynb @@ -736,7 +736,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Build Agent using Model Client\n", + "## Build an Agent with a Model Client\n", "\n", "Let's create a simple AI agent that can respond to messages using the ChatCompletion API." ] @@ -873,6 +873,21 @@ "to make the agent \"remember\" previous conversations.\n", "See the [Model Context](./model-context.ipynb) page for more details." ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## API Keys From Environment Variables\n", + "\n", + "In the examples above, we show that you can provide the API key through the `api_key` argument. Importantly, the OpenAI and Azure OpenAI clients use the [openai package](https://github.com/openai/openai-python/blob/3f8d8205ae41c389541e125336b0ae0c5e437661/src/openai/__init__.py#L260), which will automatically read an api key from the environment variable if one is not provided.\n", + "\n", + "- For OpenAI, you can set the `OPENAI_API_KEY` environment variable. \n", + "- For Azure OpenAI, you can set the `AZURE_OPENAI_API_KEY` environment variable. \n", + "\n", + "This is a good practice to explore, as it avoids including sensitive api keys in your code. \n", + "\n" + ] } ], "metadata": { From dbd3258009fba889e61cce014890c9bae2c9fa9e Mon Sep 17 00:00:00 2001 From: Victor Dibia Date: Wed, 12 Feb 2025 13:00:43 -0800 Subject: [PATCH 2/2] update sample with GEMINI api key notes --- .../user-guide/core-user-guide/components/model-clients.ipynb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python/packages/autogen-core/docs/src/user-guide/core-user-guide/components/model-clients.ipynb b/python/packages/autogen-core/docs/src/user-guide/core-user-guide/components/model-clients.ipynb index 404c478011e3..0e4c4b625c0a 100644 --- a/python/packages/autogen-core/docs/src/user-guide/core-user-guide/components/model-clients.ipynb +++ b/python/packages/autogen-core/docs/src/user-guide/core-user-guide/components/model-clients.ipynb @@ -885,6 +885,8 @@ "- For OpenAI, you can set the `OPENAI_API_KEY` environment variable. \n", "- For Azure OpenAI, you can set the `AZURE_OPENAI_API_KEY` environment variable. \n", "\n", + "In addition, for Gemini (Beta), you can set the `GEMINI_API_KEY` environment variable.\n", + "\n", "This is a good practice to explore, as it avoids including sensitive api keys in your code. \n", "\n" ]