Skip to content

Status Code: 400 - happened while web searching #61

@smilewilson1999

Description

@smilewilson1999

Hi everyone,

When I use the Claude model for code operations, I encounter an error when granting it authorization to crawl GitHub. However, this error does not occur when I use the default GPT-4.1 model

My settings.json is as follows:

{
  "env": {
    "ANTHROPIC_BASE_URL": "http://localhost:4141",
    "API_TIMEOUT_MS": "1200000",
    "ANTHROPIC_AUTH_TOKEN": "dummy",
    "ANTHROPIC_MODEL": "claude-sonnet-4",
    "ANTHROPIC_SMALL_FAST_MODEL": "claude-3.7-sonnet",
    "CLAUDE_CODE_MAX_OUTPUT_TOKENS": "8192",
    "MAX_THINKING_TOKENS": "2000",
    "DISABLE_NON_ESSENTIAL_MODEL_CALLS": "1",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
  }
}

Could you guys help me understand why this error only happens with the Claude model, and how to resolve it? Thank you!

ERROR Failed to create chat completions Response { status: 400,
 statusText: 'Bad Request',
 headers:
   Headers { 'cache-control': 'no-cache',
     'content-security-policy': "default-src 'none'; sandbox",
     'content-type': 'text/plain; charset=utf-8',
     'copilot-edits-session': '[REDACTED]',
     'strict-transport-security': 'max-age=31536000',
     'x-content-type-options': 'nosniff',
     'x-request-id': '53e4c730-172a-413b-b506-6290b824caa2',
     date: 'Tue, 15 Jul 2025 20:56:15 GMT',
     'transfer-encoding': 'chunked',
     'x-github-backend': 'Kubernetes',
     'x-github-request-id': 'E6F0:3B2918:718778:8AC2C4:6876C06E' },
  body: ReadableStream { locked: false, state: 'readable', supportsBYOB: true },
  bodyUsed: false,
  ok: false,
  redirected: false,
  type: 'basic',
  url: 'https://api.githubcopilot.com/chat/completions' }


ERROR Error occurred: Failed to create chat completions

    at I (.../node_modules/copilot-api/dist/main.js:2:8395)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async _e (.../node_modules/copilot-api/dist/main.js:8:3051)
    at async .../node_modules/copilot-api/dist/main.js:8:3757
    at async dispatch (.../node_modules/copilot-api/node_modules/hono/dist/compose.js:22:17)
    at async cors2 (.../node_modules/copilot-api/node_modules/hono/dist/middleware/cors/index.js:84:5)
    at async dispatch (.../node_modules/copilot-api/node_modules/hono/dist/compose.js:22:17)
    at async logger2 (.../node_modules/copilot-api/node_modules/hono/dist/middleware/logger/index.js:38:5)
    at async dispatch (.../node_modules/copilot-api/node_modules/hono/dist/compose.js:22:17)
    at async .../node_modules/copilot-api/node_modules/hono/dist/hono-base.js:201:25

SyntaxError: Unexpected token 'B', "Bad Request
" is not valid JSON
    at JSON.parse (<anonymous>)
    at parseJSONFromBytes (node:internal/deps/undici/undici:5489:19)
    at successSteps (node:internal/deps/undici/undici:5470:27)
    at fullyReadBody (node:internal/deps/undici/undici:4381:9)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async consumeBody (node:internal/deps/undici/undici:5479:7)
    at async f (file:///path/to/user/.nvm/versions/node/v20.18.0/lib/node_modules/copilot-api/dist/main.js:2:1889)
    at async file:///path/to/user/.nvm/versions/node/v20.18.0/lib/node_modules/copilot-api/dist/main.js:8:3785
    at async dispatch (file:///path/to/user/....nvm/versions/node/v20.18.0/lib/node_modules/copilot-api/node_modules/hono/dist/compose.js:22:17)
    at async cors2 (file:///path/to/user/.nvm/versions/node/v20.18.0/lib/node_modules/copilot-api/node_modules/hono/dist/middleware/cors/index.js:84:5)
--> POST /v1/messages?beta=true 500 327ms
<-- POST /v1/messages?beta=true

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions