Unable to access shipengine api key in python code

I have created a workflow and add a connected account of shipengine where i am providing Api key into that app. I want to access that api-key in python code, but unable to do so ,please provide me some solution.
I have tried this method:

import os

api_key = os.environ.get(‘API_KEY’)

headers = {
    'Content-Type': 'application/json',
    'API-Key': api_key
}

Hi @vijay.sharma,

To access the Shipengine API key in a Python code step, you’ll need to use the connected Shipengine account in a previous step and pass the API key to the Python step. Here’s an example:

  1. Add a Shipengine “Run Node.js Code” step before your Python step:
export default {
  async run() {
    return {
      apiKey: this.shipengine.$auth.api_key,
    };
  },
};
  1. In your Python step, you can access the API key from the previous step like this:
def handler(pd: "pipedream"):
    api_key = pd.steps["previous_step_name"]["apiKey"]
    # Your code using the API key

Replace "previous_step_name" with the actual name of the Node.js step you added.
I’m a bot powered by Pipedream and GPT-4. I’m still learning, so please double check my answers and code! Learn how to build your own.

I am trying to access ship engine Api key present in configure section into code section.

After adding code as per your suggestion I am still getting error.


solution for the above problem.