mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-30 17:24:59 +00:00
![]() # Context: USER: is it possible to add OPEN_AI_BASE or openai.api_base endpoint default: openai.api_base = "https://api.openai.com/v1/chat/completions" ASSISTANT: Yes, you can add an option to set the OpenAI API base endpoint. Here's how to do it: 1. Add a new argument to the argument parser in `aider/main.py`. 2. Set the `openai.api_base` in the `Coder` class in `aider/coder.py`. Here are the changes you need to make: ```python aider/main.py <<<<<<< ORIGINAL parser.add_argument( "--openai-api-key", metavar="OPENAI_API_KEY", help="Specify the OpenAI API key", env_var="OPENAI_API_KEY", ) ======= parser.add_argument( "--openai-api-key", metavar="OPENAI_API_KEY", help="Specify the OpenAI API key", env_var="OPENAI_API_KEY", ) parser.add_argument( "--openai-api-base", metavar="OPENAI_API_BASE", default="https://api.openai.com/v1/chat/completions", help="Specify the OpenAI API base endpoint (default: https://api.openai.com/v1/chat/completions)", ) >>>>>>> UPDATED ``` ```python aider/coder.py <<<<<<< ORIGINAL if openai_api_key: openai.api_key = openai_api_key else: raise MissingAPIKeyError("No OpenAI API key provided.") ======= if not openai_api_key: raise MissingAPIKeyError("No OpenAI API key provided.") openai.api_key = openai_api_key openai.api_base = args.openai_api_base >>>>>>> UPDATED ``` Now you can use the `--openai-api-base` option to set the OpenAI API base endpoint when running the script. |
||
---|---|---|
.. | ||
__init__.py | ||
coder.py | ||
commands.py | ||
diffs.py | ||
dump.py | ||
io.py | ||
main.py | ||
models.py | ||
prompts.py | ||
repomap.py | ||
utils.py |