Goose API key setup
Goose API Key: Set Your Own Key in config.yaml
Paste the block below into config.yaml, put your own API key in ~/.bashrc, and Goose can use Claude models. Pay as you go.
GOOSE_PROVIDER: openai
GOOSE_MODEL: claude-haiku-4-5-20251001
OPENAI_HOST: https://api.aicodewith.ai
OPENAI_BASE_PATH: v1/chat/completionsSetup steps
Save this key for later terminals
Once you are signed in, this command includes your own key. Copy it, run it once, and the tool keeps the key in the location we tested.
for rc in "$HOME/.zshrc" "$HOME/.bashrc"; do
touch "$rc"
echo 'export OPENAI_API_KEY=sk-***' >> "$rc"
doneSigned-out visitors only see a placeholder. Sign in and we fill in your key. Get a key in the console
Copying only puts the command on the clipboard. You still need to run it in a terminal, or paste the key into the tool settings. How to get an API key
These steps were tested on Linux (bash). macOS and Windows have not been tested yet, so they are not listed.
No Goose yet? Install it (skip if installed)
Run
curl -fsSL https://github.com/aaif-goose/goose/releases/download/stable/download_cli.sh | CONFIGURE=false bash, thengoose --version. A version number means it is installed.Install Goose: curl -fsSL https://github.com/aaif-goose/goose/releases/download/stable/download_cli.sh | CONFIGURE=false bash (CONFIGURE=false skips the interactive setup). It installs to ~/.local/bin/goose. goose --version prints 1.54.0 Paste the config into config.yaml
Open
~/.config/goose/config.yaml, paste the block from the top of this page, and save. You no longer need to export these.The endpoint in ~/.config/goose/config.yaml Put your API key in ~/.bashrc
Run
echo 'export OPENAI_API_KEY=sk-***' >> ~/.bashrc, replacingsk-***with your API key (Get an API key). The last line of~/.bashrcshould be that line.Check that the last line of ~/.bashrc is export OPENAI_API_KEY=sk-*** (masked here) Open a new terminal and test Goose
Open a new terminal and run
goose run --no-session --quiet --max-turns 1 -t "Reply with exactly: OK".OKmeans Goose is using your API key.Verify: close the terminal, open a new one, run goose run --no-session --quiet --max-turns 1 -t "Reply with exactly: OK"; an OK reply means it is set up No OK? Match your error
Compare the error in your terminal with Common errors below. Each one lists the cause and the fix.
Switch Goose models: change GOOSE_MODEL
Replace the model name after
GOOSE_MODELin config.yaml with the new Model ID, spelled exactly. Model IDs are on Models and pricing.
Common errors
No key set: Authentication failed for https://api.aicodewith.ai/v1/chat/completions. Status: 401 Unauthorized. Response: {"error":"请在请求中提供有效的 API Key。"}
What you see
error: Ran into this error: Authentication error: Authentication failed for https://api.aicodewith.ai/v1/chat/completions. Status: 401 Unauthorized. Response: {"error":"请在请求中提供有效的 API Key。"}.
(English: "Please provide a valid API key in the request.")- Cause
- The terminal has no OPENAI_API_KEY: it is not in ~/.bashrc, or you added it but did not open a new terminal
- How to fix
- Put the key in ~/.bashrc as in step 3, then open a new terminal
Go back to step 3: Put your API key in ~/.bashrc →
Wrong key: Authentication failed for https://api.aicodewith.ai/v1/chat/completions. Status: 401 Unauthorized. Response: {"error":"请在请求中提供有效的 API Key。"}
What you see
error: Ran into this error: Authentication error: Authentication failed for https://api.aicodewith.ai/v1/chat/completions. Status: 401 Unauthorized. Response: {"error":"请在请求中提供有效的 API Key。"}.
(English: "Please provide a valid API key in the request.")- Cause
- OPENAI_API_KEY in ~/.bashrc is wrong; the error is the same as with no key
- How to fix
- Copy the key from the console again, fix the last line of ~/.bashrc, then open a new terminal
Go back to step 3: Put your API key in ~/.bashrc →
404 "不支持的请求路径" (unsupported request path)
What you see
404 "不支持的请求路径" (unsupported request path)
- Cause
- OPENAI_BASE_PATH is wrong (for example nope/chat/completions), so the request goes to https://api.aicodewith.ai/nope/chat/completions
- How to fix
- Set it back to v1/chat/completions
Go back to step 2: Paste the config into config.yaml →
FAQ
How do I use my own API key in Goose?
In ~/.config/goose/config.yaml, set GOOSE_PROVIDER: openai, OPENAI_HOST: https://api.aicodewith.ai and OPENAI_BASE_PATH: v1/chat/completions, then add export OPENAI_API_KEY=your key to ~/.bashrc.
Should the Goose OPENAI_HOST include /v1?
No. Set OPENAI_HOST to https://api.aicodewith.ai and put /v1 in OPENAI_BASE_PATH.
Goose says 401. What now?
The terminal has no OPENAI_API_KEY, or the key is wrong. See Common errors above for the fix.
Goose can't find the model. What now?
Make sure GOOSE_MODEL matches an AI Code With Model ID exactly.
Sources
- Goose Providers docs
- Goose GitHub repository (aaif-goose/goose, install script source)
- Goose installation docs