Skip to content

feat(provider): honor ANTHROPIC_BASE_URL in native Anthropic provider #195

Description

@rodboev

Summary

The native Anthropic provider reads ANTHROPIC_API_KEY, but it does not honor an ANTHROPIC_BASE_URL override. That prevents SkillSpector from using Anthropic-compatible local or corporate gateways that expose the standard Anthropic Messages API shape at a private base URL.

The OpenAI provider already supports the equivalent pattern with OPENAI_BASE_URL, so this is an inconsistent provider configuration surface.

Current Behavior

With an environment like:

SKILLSPECTOR_PROVIDER=anthropic
ANTHROPIC_API_KEY=<local gateway key>
ANTHROPIC_BASE_URL=http://localhost:8317

SkillSpector still constructs ChatAnthropic with the hardcoded https://api.anthropic.com base URL. The local key is only valid against the local gateway, so LLM-backed scans and integration tests cannot use this provider path.

anthropic_proxy is a separate raw-predict provider that requires ANTHROPIC_PROXY_ENDPOINT_URL; it does not cover the standard Anthropic Messages API base-URL override case.

Expected Behavior

AnthropicProvider should read an optional ANTHROPIC_BASE_URL env var and pass it to ChatAnthropic, defaulting to https://api.anthropic.com when unset.

This would make the native Anthropic path match the OpenAI provider's override behavior while preserving the existing default for normal Anthropic users.

Root Cause Evidence

src/skillspector/providers/anthropic/provider.py currently:

  • defines ANTHROPIC_BASE_URL = "https://api.anthropic.com"
  • reads only ANTHROPIC_API_KEY in resolve_credentials()
  • passes the constant ANTHROPIC_BASE_URL into ChatAnthropic(...)

Proposed Scope

  • Add optional ANTHROPIC_BASE_URL support to the native Anthropic provider.
  • Keep ANTHROPIC_API_KEY as the credential env var.
  • Keep the current default base URL when the override is unset.
  • Add provider unit coverage for default and overridden base URL behavior.

Non-Goals

  • No change to anthropic_proxy raw-predict behavior.
  • No new credential env var.
  • No change to OpenAI or NVIDIA provider selection.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions