Skip to content

all requests fail with "AI_APICallError: Bad Request" #678

Closed

Description

@zkdiff

session share: https://opencode.ai/s/Y7W3NNLv

auth list log

@zkdiff ➜ /workspaces/20250703-0 (main) $ opencode --print-logs auth list
INFO  2025-07-04T07:42:03 +69ms service=default version=0.1.189 args=--print-logs,auth,list opencode

┌  Credentials ~/.local/share/opencode/auth.json
INFO  2025-07-04T07:42:03 +5ms service=models.dev refreshing
│
└  0 credentials

┌  Environment
│
●  GitHub Copilot GITHUB_TOKEN
│
└  1 environment variables

models log

@zkdiff ➜ /workspaces/20250703-0 (main) $ opencode --print-logs models
INFO  2025-07-04T07:41:05 +68ms service=default version=0.1.189 args=--print-logs,models opencode
INFO  2025-07-04T07:41:05 +1ms service=app cwd=/workspaces/20250703-0 creating
INFO  2025-07-04T07:41:05 +2ms service=app git=/workspaces/20250703-0 git
INFO  2025-07-04T07:41:05 +5ms service=app name=provider registering service
INFO  2025-07-04T07:41:05 +2ms service=app name=config registering service
INFO  2025-07-04T07:41:05 +2ms service=config loaded
INFO  2025-07-04T07:41:05 +1ms service=models.dev refreshing
INFO  2025-07-04T07:41:05 +0ms service=provider init
INFO  2025-07-04T07:41:05 +4ms service=provider providerID=github-copilot found
github-copilot/gemini-2.5-pro
github-copilot/claude-3.5-sonnet
github-copilot/o3-mini
github-copilot/gpt-4.1
github-copilot/claude-3.7-sonnet
github-copilot/claude-3.7-sonnet-thought
github-copilot/o4-mini
github-copilot/o1
github-copilot/gemini-2.0-flash-001
github-copilot/gpt-4o
github-copilot/claude-sonnet-4

session log

@zkdiff ➜ /workspaces/20250703-0 (main) $ opencode --print-logs run "/init"
INFO  2025-07-04T07:38:48 +74ms service=default version=0.1.189 args=--print-logs,run,/init opencode
INFO  2025-07-04T07:38:48 +0ms service=app cwd=/workspaces/20250703-0 creating
INFO  2025-07-04T07:38:48 +3ms service=app git=/workspaces/20250703-0 git
INFO  2025-07-04T07:38:48 +1ms service=bus type=storage.write subscribing
INFO  2025-07-04T07:38:48 +1ms service=app name=bus registering service
INFO  2025-07-04T07:38:48 +0ms service=format init
INFO  2025-07-04T07:38:48 +0ms service=bus type=file.edited subscribing
INFO  2025-07-04T07:38:48 +0ms service=config.hooks init
INFO  2025-07-04T07:38:48 +1ms service=bus type=file.edited subscribing
INFO  2025-07-04T07:38:48 +2ms service=bus type=session.idle subscribing
INFO  2025-07-04T07:38:48 +1ms service=app name=lsp registering service
INFO  2025-07-04T07:38:48 +0ms service=lsp initializing
INFO  2025-07-04T07:38:48 +1ms service=app name=file.watcher registering service
INFO  2025-07-04T07:38:48 +1ms service=session id=ses_82ba055aaffe7dDyjjQ26C9VU5 version=0.1.189 title=New Session - 2025-07-04T07:38:48.789Z time=[object Object] created
INFO  2025-07-04T07:38:48 +0ms service=app name=session registering service
INFO  2025-07-04T07:38:48 +1ms service=app name=storage registering service
INFO  2025-07-04T07:38:48 +0ms service=storage path=/home/codespace/.local/share/opencode/project/workspaces-20250703-0/storage init
INFO  2025-07-04T07:38:48 +4ms service=bus type=storage.write publishing
INFO  2025-07-04T07:38:48 +1ms service=app name=config registering service
INFO  2025-07-04T07:38:48 +3ms service=config loaded
INFO  2025-07-04T07:38:48 +0ms service=bus type=session.updated publishing

█▀▀█ █▀▀█ █▀▀ █▀▀▄ █▀▀ █▀▀█ █▀▀▄ █▀▀
█░░█ █░░█ █▀▀ █░░█ █░░ █░░█ █░░█ █▀▀
▀▀▀▀ █▀▀▀ ▀▀▀ ▀  ▀ ▀▀▀ ▀▀▀▀ ▀▀▀  ▀▀▀

>  /init

INFO  2025-07-04T07:38:48 +2ms service=app name=provider registering service
INFO  2025-07-04T07:38:48 +3ms service=models.dev refreshing
INFO  2025-07-04T07:38:48 +0ms service=provider init
INFO  2025-07-04T07:38:48 +3ms service=provider providerID=github-copilot found
@  github-copilot/claude-sonnet-4

INFO  2025-07-04T07:38:48 +2ms service=bus type=message.part.updated subscribing
INFO  2025-07-04T07:38:48 +2ms service=session session=ses_82ba055aaffe7dDyjjQ26C9VU5 chatting
INFO  2025-07-04T07:38:48 +1ms service=provider providerID=github-copilot modelID=claude-sonnet-4 getModel
INFO  2025-07-04T07:38:48 +0ms service=provider status=started providerID=github-copilot getSDK
INFO  2025-07-04T07:38:48 +44ms service=provider status=completed duration=44 providerID=github-copilot getSDK
INFO  2025-07-04T07:38:48 +4ms service=provider providerID=github-copilot modelID=claude-sonnet-4 found
INFO  2025-07-04T07:38:48 +4ms service=session sessionID=ses_82ba055aaffe7dDyjjQ26C9VU5 locking
INFO  2025-07-04T07:38:48 +13ms service=snapshot creating snapshot
INFO  2025-07-04T07:38:48 +24ms service=snapshot initialized
INFO  2025-07-04T07:38:48 +13ms service=snapshot added files
INFO  2025-07-04T07:38:48 +12ms service=snapshot commit
INFO  2025-07-04T07:38:48 +2ms service=bus type=storage.write publishing
INFO  2025-07-04T07:38:48 +1ms service=bus type=message.updated publishing
INFO  2025-07-04T07:38:48 +17ms service=bus type=storage.write publishing
INFO  2025-07-04T07:38:48 +1ms service=bus type=message.updated publishing
INFO  2025-07-04T07:38:48 +1ms service=app name=mcp registering service
INFO  2025-07-04T07:38:49 +54ms service=lsp initialized
ERROR 2025-07-04T07:38:49 +295ms service=session error=AI_APICallError: Bad Request callback error
INFO  2025-07-04T07:38:49 +1ms service=bus type=session.error publishing
INFO  2025-07-04T07:38:49 +1ms service=session session=ses_82ba055aaffe7dDyjjQ26C9VU5 type=error part
INFO  2025-07-04T07:38:49 +0ms service=session session=ses_82ba055aaffe7dDyjjQ26C9VU5 type=error unhandled
INFO  2025-07-04T07:38:49 +1ms service=bus type=storage.write publishing
INFO  2025-07-04T07:38:49 +0ms service=bus type=message.updated publishing
INFO  2025-07-04T07:38:49 +0ms service=session sessionID=ses_82ba055aaffe7dDyjjQ26C9VU5 unlocking
INFO  2025-07-04T07:38:49 +1ms service=bus type=session.idle publishing
INFO  2025-07-04T07:38:49 +0ms service=app name=lsp shutdown
INFO  2025-07-04T07:38:49 +0ms service=app name=file.watcher shutdown
INFO  2025-07-04T07:38:49 +0ms service=app name=session shutdown
INFO  2025-07-04T07:38:49 +0ms service=app name=mcp shutdown

Activity

  1. zkdiff commented on Jul 4, 2025

    @zkdiff
    Author

    Same error occurs after explicitly authenticating

    @zkdiff ➜ /workspaces/20250703-0 (main) $ opencode auth list
    
    ┌  Credentials
    │
    ●  GitHub Copilot (api)
    │
    └  1 credentials
    
    @zkdiff ➜ /workspaces/20250703-0 (main) $ opencode --print-logs run "/init"
    2025-07-04T07:46:29 +75ms service=default version=0.1.100 args=--print-logs,run,/init opencode
    2025-07-04T07:46:29 +1ms service=app cwd=/workspaces/20250703-0 creating
    2025-07-04T07:46:29 +2ms service=app git=/workspaces/20250703-0 git
    2025-07-04T07:46:29 +2ms service=app name=share registering service
    2025-07-04T07:46:29 +1ms service=bus type=storage.write subscribing
    2025-07-04T07:46:29 +0ms service=app name=bus registering service
    2025-07-04T07:46:29 +4ms service=session id=ses_82b994f2bffebc0ada9c5220c4 version=0.1.100 title=New Session - 2025-07-04T07:46:29.205Z time=[object Object] created
    2025-07-04T07:46:29 +0ms service=app name=session registering service
    2025-07-04T07:46:29 +0ms service=app name=storage registering service
    2025-07-04T07:46:29 +0ms service=storage path=/home/codespace/.local/share/opencode/project/-workspaces-20250703-0/storage init
    2025-07-04T07:46:29 +1ms service=bus type=storage.write publishing
    2025-07-04T07:46:29 +0ms service=app name=config registering service
    2025-07-04T07:46:29 +2ms service=config loaded
    2025-07-04T07:46:29 +0ms service=bus type=session.updated publishing
    
    █▀▀█ █▀▀█ █▀▀ █▀▀▄ █▀▀ █▀▀█ █▀▀▄ █▀▀
    █░░█ █░░█ █▀▀ █░░█ █░░ █░░█ █░░█ █▀▀
    ▀▀▀▀ █▀▀▀ ▀▀▀ ▀  ▀ ▀▀▀ ▀▀▀▀ ▀▀▀  ▀▀▀
    
    >  /init
    
    2025-07-04T07:46:29 +1ms service=app name=provider registering service
    2025-07-04T07:46:29 +2ms service=models.dev refreshing
    2025-07-04T07:46:29 +1ms service=provider init
    2025-07-04T07:46:29 +3ms service=provider providerID=github-copilot found
    @  github-copilot/claude-sonnet-4
    
    2025-07-04T07:46:29 +3ms service=bus type=message.part.updated subscribing
    2025-07-04T07:46:29 +2ms service=session session=ses_82b994f2bffebc0ada9c5220c4 chatting
    2025-07-04T07:46:29 +2ms service=provider providerID=github-copilot modelID=claude-sonnet-4 getModel
    2025-07-04T07:46:29 +0ms service=provider status=started providerID=github-copilot getSDK
    2025-07-04T07:46:29 +47ms service=provider status=completed duration=47 providerID=github-copilot getSDK
    2025-07-04T07:46:29 +2ms service=provider providerID=github-copilot modelID=claude-sonnet-4 found
    2025-07-04T07:46:29 +2ms service=session sessionID=ses_82b994f2bffebc0ada9c5220c4 locking
    2025-07-04T07:46:29 +15ms service=bus type=storage.write publishing
    2025-07-04T07:46:29 +0ms service=bus type=message.updated publishing
    2025-07-04T07:46:29 +11ms service=bus type=storage.write publishing
    2025-07-04T07:46:29 +0ms service=bus type=message.updated publishing
    2025-07-04T07:46:29 +1ms service=app name=mcp registering service
    2025-07-04T07:46:29 +352ms service=session error=AI_APICallError: Bad Request callback error
    2025-07-04T07:46:29 +0ms message=AI_APICallError: Bad Request cause=AI_APICallError: Bad Request UnknownError
    2025-07-04T07:46:29 +0ms service=bus type=session.error publishing
    2025-07-04T07:46:29 +1ms service=session session=ses_82b994f2bffebc0ada9c5220c4 type=error part
    2025-07-04T07:46:29 +0ms service=session session=ses_82b994f2bffebc0ada9c5220c4 type=error unhandled
    2025-07-04T07:46:29 +3ms service=bus type=storage.write publishing
    2025-07-04T07:46:29 +0ms service=bus type=message.updated publishing
    2025-07-04T07:46:29 +0ms service=session sessionID=ses_82b994f2bffebc0ada9c5220c4 unlocking
    2025-07-04T07:46:29 +1ms service=app name=session shutdown
    2025-07-04T07:46:29 +0ms service=app name=mcp shutdown
    
  2. self-assigned this
    on Jul 4, 2025
  3. danriedl commented on Jul 8, 2025

    @danriedl

    Probably related #739 . Try disabling all MCP Server, if configured.

  4. zkdiff commented on Jul 8, 2025

    @zkdiff
    Author

    This is reproduced with a blank slate environment so while I can't say whether it is related to #739 or not, I would guess this particular defect is not related to MCP. I'll be able to dig into it in a couple of days if it is still an issue.

    CODESPACE=$(gh codespace create --repo github/codespaces-blank --branch main --machine basicLinux32gb | tail -1) && \
    echo "Created codespace: $CODESPACE" && \
    gh codespace ssh --codespace "$CODESPACE" << 'EOF'
    curl -fsSL https://opencode.ai/install | bash
    ~/.opencode/bin/opencode run bizzfuzz
    EOF
    gh codespace delete --codespace "$CODESPACE"
    
  5. llucax commented on Jul 10, 2025

    @llucax

    Experiencing the same issue here after a first fresh install.

  6. zkdiff commented on Jul 10, 2025

    @zkdiff
    Author

    Experiencing the same issue here after a first fresh install.

    @llucax are you use a GitHub codespace? If you aren't, do you have GITHUB_TOKEN set in your env?

  7. llucax commented on Jul 11, 2025

    @llucax

    I'm not using a GitHub codepace, running locally. I configured the token manually via auth login:

    $opencode auth list
    
    ┌  Credentials ~/.local/share/opencode/auth.json
    │
    ●  GitHub Copilot api
    │
    └  1 credentials
    

    I got the token from ~/.config/github-copilot/hosts.json as instructed in https://github.com/opencode-ai/opencode#using-github-copilot (I use both VSCode and copilot in nvim, not sure which one configured that token, but both work fine with copilot).

  8. tomwojcik commented on Jul 25, 2025

    @tomwojcik

    I run into this issue a few times in a row. I run a new session with logs, it complained about pyright not running. I installed it (npm install -g pyright) and so far so good, but I can't confirm it fixed the issue for good.

  9. rekram1-node commented on Sep 25, 2025

    @rekram1-node
    Contributor

    is this still an issue?

  10. coleleavitt commented on Oct 3, 2025

    @coleleavitt
    Contributor

    is this still an issue?

    yes I am getting it, gonna try to debug it

  11. vapvarun commented on Oct 3, 2025

    @vapvarun

    I ran into the same error, and in my case it happened right after I pasted an image into the terminal for additional context. After that, the error kept appearing. Opening a fresh terminal window resolved the issue for me.

  12. coleleavitt commented on Oct 3, 2025

    @coleleavitt
    Contributor

    I ran into the same error, and in my case it happened right after I pasted an image into the terminal for additional context. After that, the error kept appearing. Opening a fresh terminal window resolved the issue for me.

    I figured out that the issue happens on grok 4 fast for me specifically due to tool limitations as I got over 200 tools for one local MCP server which is out of the scope of grok 4 fast. I'll test with my claude account but I think there needs to be an improvement in the error handling

  13. jcubic commented on Oct 3, 2025

    @jcubic

    I had the same problem. But I had GITHUB_TOKEN in my ~/.bashrc. Removing the variable solved the issue.

  14. coleleavitt commented on Oct 3, 2025

    @coleleavitt
    Contributor

    I had the same problem. But I had GITHUB_TOKEN in my ~/.bashrc. Removing the variable solved the issue.

    I think we come to the consensus that there needs to be more detailed/robust error handling

  15. thdxr commented on Mar 25, 2026

    @thdxr
    Member

    To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions