Skip to content

fails to authenticate when using openrouter and claude sonnet 4.5 #58

@motcke

Description

@motcke

I tried to create a new api key, checked for hidden spaces, etc., and my key seems valid.

Here's my GitHub workflow:

name: Presubmit.ai

permissions:
  contents: read
  pull-requests: write
  issues: write

on:
  pull_request_target:
    types: [opened, synchronize]
  pull_request_review_comment:
    types: [created]

jobs:
  review:
    runs-on: ubuntu-latest
    steps:
      - name: Check required secrets
        run: |
          if [ -z "${{ secrets.OPEN_ROUTER_API_KEY }}" ]; then
            echo "Error: OPEN_ROUTER_API_KEY secret is not configured."
            exit 1
          fi
      - uses: presubmit/ai-reviewer@latest
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          LLM_PROVIDER: "ai-sdk"
          LLM_BASE_URL: "https://openrouter.ai/api/v1"
          LLM_MODEL: "claude-sonnet-4-5"
          LLM_API_KEY: ${{ secrets.OPEN_ROUTER_API_KEY }}

and I get the following error:

...
...
...
    tools: [
      {
        name: 'json',
        description: 'Respond with a JSON object.',
        input_schema: {
          type: 'object',
          properties: {
            title: [Object],
            description: [Object],
            files: [Object],
            type: [Object]
          },
          required: [ 'title', 'description', 'files', 'type' ],
          additionalProperties: false,
          '$schema': 'http://json-schema.org/draft-07/schema#'
        }
      }
    ],
    tool_choice: { type: 'tool', name: 'json' }
  },
  statusCode: 401,
  responseHeaders: {
    'cf-cache-status': 'DYNAMIC',
    'cf-ray': '9c7981c5da30dae8-ORD',
    connection: 'keep-alive',
    'content-length': '130',
    'content-security-policy': "default-src 'none'; frame-ancestors 'none'",
    'content-type': 'application/json',
    date: 'Mon, 02 Feb 2026 11:56:44 GMT',
    'request-id': 'req_011CWjCbSjoaombyPAwea6UM',
    server: 'cloudflare',
    'strict-transport-security': 'max-age=31536000; includeSubDomains; preload',
    'x-envoy-upstream-service-time': '195',
    'x-robots-tag': 'none',
    'x-should-retry': 'false'
  },
  responseBody: '{"type":"error","error":{"type":"authentication_error","message":"invalid x-api-key"},"request_id":"req_011CWjCbSjoaombyPAwea6UM"}',
  isRetryable: false,
  data: {
    type: 'error',
    error: { type: 'authentication_error', message: 'invalid x-api-key' }
  },
  [Symbol(vercel.ai.error)]: true,
  [Symbol(vercel.ai.error.AI_APICallError)]: true
}
Node.js v20.19.6

My open router account shows 0 use (and I have credits):

Image

Metadata

Metadata

Assignees

No one assigned

    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