if-ai / ComfyUI-IF_AI_tools

ComfyUI-IF_AI_tools is a set of custom nodes for ComfyUI that allows you to generate prompts using a local Large Language Model (LLM) via Ollama. This tool enables you to enhance your image generation workflow by leveraging the power of language models.
https://ko-fi.com/impactframes
368 stars 27 forks source link

Where to Set enviromnet variables? #4

Closed Tobe2d closed 2 months ago

Tobe2d commented 3 months ago

I woud like to know where to Set enviromnet variables for "ANTHROPIC_API_KEY" & "OPENAI_API_KEY"

I am getting this at the end of the log when I start comfyui

Error: ANTHROPIC_API_KEY is required
Error: OPENAI_API_KEY is required
Error: ANTHROPIC_API_KEY is required
Error: OPENAI_API_KEY is required
if-ai commented 3 months ago

This is optional if you have ollama but if you want to use openai or anthropic APIs , you have to set your system environment variables with the API key.

For Windows:

  1. Open the Start menu and search for "Environment Variables".
  2. Click on "Edit the system environment variables".
  3. In the System Properties window, click on the "Environment Variables" button.
  4. In the "User variables" section, click on the "New" button.
  5. Set the variable name as "ANTHROPIC_API_KEY" and enter your Anthropic API key as the value.
  6. Click "OK" to save the variable.
  7. Repeat steps 4-6 to create another variable named "OPENAI_API_KEY" with your OpenAI API key as the value.
  8. Click "OK" to close all the windows.

For Linux:

  1. Open a terminal.
  2. Open the shell configuration file (e.g., ~/.bashrc or ~/.zshrc) using a text editor. For example:
    nano ~/.bashrc
  3. Add the following lines at the end of the file, replacing YOUR_ANTHROPIC_API_KEY and YOUR_OPENAI_API_KEY with your actual API keys:
    export ANTHROPIC_API_KEY="YOUR_ANTHROPIC_API_KEY"
    export OPENAI_API_KEY="YOUR_OPENAI_API_KEY"
  4. Save the file and exit the text editor. For nano, press Ctrl+X, then Y, and finally Enter.
  5. Reload the shell configuration by running the following command:
    source ~/.bashrc

After setting the environment variables, restart ComfyUI the API keys should be accessible then