From the course: OpenAI API: Agents

Unlock this course with a free trial

Join today to access over 24,800 courses taught by industry experts.

Authentication

Authentication

- A quick word on authentication, to run the OpenAI agent's SDK you need to validate it using your API key. But you'll have noticed in these examples there are no references to the API key. That's because the agent's SDK assumes there's already an OpenAI API key sitting as a variable in the environment. And that means you can simply export OpenAI_API_key with your API key into the environment and it'll automatically be used. Or if you want to be more explicit, you can add a dot N file with OpenAI_API_key and your key into your environment and then pull it in like you normally would with dot N. Now, all that said, there are situations where you need to customize how the key is loaded and there are contingencies for that as well. You can use the set default OpenAI key function to declare a default OpenAI key in your application. You can even more explicitly declare the OpenAI key by hooking into the async OpenAI function. And finally, you can declare which API you want to use and then…

Contents