Skip to content

A programming framework for agentic AI

Update Model Client Docs to Mention API Key from Environment Variables (#5515)

Victor Dibia559aea9f5b71
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 df6bb2d1a..0e4c4b625 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,23 @@
"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",
+ "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"
+ ]
}
],
"metadata": {