How to Configure Different LLM Providers Like OpenAI, Anthropic, and Bedrock in SkillSpector
Set the SKILLSPECTOR_PROVIDER environment variable to openai, anthropic, or bedrock, configure the corresponding credentials, and SkillSpector will automatically route all chat-model operations through your chosen backend.
SkillSpector is an open-source code analysis tool by NVIDIA that supports multiple LLM backends for semantic quality analysis. To configure different LLM providers like OpenAI, Anthropic, and Bedrock in SkillSpector, you manipulate environment variables that control provider selection, credential resolution, and model overrides. The system implements a pluggable provider architecture located in src/skillspector/providers/, allowing seamless switching between cloud AI services without modifying application code.
Provider Selection via Environment Variables
SkillSpector initializes its LLM backend at startup by reading the SKILLSPECTOR_PROVIDER variable. If this variable is unset, the system defaults to the NVIDIA build provider. When the specified provider fails to instantiate—for example, due to missing credentials—SkillSpector falls back to the standard OpenAI provider according to the logic in src/skillspector/providers/__init__.py (lines 70-99).
OpenAI Configuration
The OpenAI provider is implemented in src/skillspector/providers/openai/provider.py via the OpenAIProvider class. It requires the OPENAI_API_KEY environment variable and optionally accepts OPENAI_BASE_URL for custom endpoints. The default model is gpt-5.4 when SKILLSPECTOR_MODEL is not specified.
export SKILLSPECTOR_PROVIDER=openai
export OPENAI_API_KEY=sk-xxxx
# Optional: custom base URL
export OPENAI_BASE_URL=https://api.openai.com/v1
Anthropic Configuration
The Anthropic provider uses the AnthropicProvider class in src/skillspector/providers/anthropic/provider.py. It requires ANTHROPIC_API_KEY. The default model is claude-opus-4-6, though the system automatically uses claude-sonnet-4-6 for the meta_analyzer slot unless overridden.
export SKILLSPECTOR_PROVIDER=anthropic
export ANTHROPIC_API_KEY=sk-ant-xxxx
AWS Bedrock Configuration
The Bedrock provider (BedrockProvider in src/skillspector/providers/bedrock/provider.py) does not use explicit API keys. Instead, it relies on the standard boto3 credential chain, supporting AWS_PROFILE, AWS_REGION, EC2 instance metadata, or IAM roles. The default model is us.anthropic.claude-sonnet-4-6-20250915-v1:0.
export SKILLSPECTOR_PROVIDER=bedrock
export AWS_PROFILE=my-aws-profile
export AWS_REGION=us-west-2
Model Overrides and Slot-Specific Configuration
You can override the default model for all operations by setting SKILLSPECTOR_MODEL. For specialized analysis slots—such as the meta_analyzer—use the pattern SKILLSPECTOR_MODEL_<SLOT> to assign different models to different tasks. This resolution logic resides in src/skillspector/providers/base.py.
# Override default model for OpenAI
export SKILLSPECTOR_MODEL=gpt-4-turbo
# Use a specific model for the meta analyzer slot
export SKILLSPECTOR_MODEL_META_ANALYZER=claude-sonnet-4-6
Programmatic Provider Access
For Python-based workflows, import get_chat_model from skillspector.llm_utils to obtain a configured chat instance. The function respects all environment variables and returns a native LangChain chat model (e.g., ChatOpenAI, ChatAnthropic, or ChatBedrockConverse).
import os
from skillspector.llm_utils import get_chat_model
# Configure provider
os.environ["SKILLSPECTOR_PROVIDER"] = "anthropic"
os.environ["ANTHROPIC_API_KEY"] = "sk-ant-xxxx"
os.environ["SKILLSPECTOR_MODEL"] = "claude-opus-4-6"
# Initialize model
chat = get_chat_model(max_tokens=512, timeout=60)
response = chat.invoke("Explain the difference between a function and a method.")
print(response.content)
Quick-Switch Bash Functions
To streamline testing across providers, define shell functions that isolate credential sets:
#!/usr/bin/env bash
set -e
use_openai() {
export SKILLSPECTOR_PROVIDER=openai
export OPENAI_API_KEY="${OPENAI_API_KEY:?set it}"
unset ANTHROPIC_API_KEY AWS_PROFILE AWS_REGION
echo "✅ OpenAI selected"
}
use_anthropic() {
export SKILLSPECTOR_PROVIDER=anthropic
export ANTHROPIC_API_KEY="${ANTHROPIC_API_KEY:?set it}"
unset OPENAI_API_KEY AWS_PROFILE AWS_REGION
echo "✅ Anthropic selected"
}
use_bedrock() {
export SKILLSPECTOR_PROVIDER=bedrock
export AWS_PROFILE="${AWS_PROFILE:-default}"
export AWS_REGION="${AWS_REGION:-us-west-2}"
unset OPENAI_API_KEY ANTHROPIC_API_KEY
echo "✅ Bedrock selected (profile=$AWS_PROFILE, region=$AWS_REGION)"
}
Key Implementation Files
The provider architecture spans these critical files:
src/skillspector/providers/__init__.py— Provider selector logic and OpenAI fallback implementation (lines 70-99)src/skillspector/providers/openai/provider.py—OpenAIProviderclass withresolve_credentials()andcreate_chat_model()methods (lines 52-74)src/skillspector/providers/anthropic/provider.py—AnthropicProviderimplementation (lines 50-77)src/skillspector/providers/bedrock/provider.py—BedrockProviderwith boto3 integration andChatBedrockConverseclient creation (lines 64-134)src/skillspector/providers/base.py— Shared model resolution helpers for slot-specific overridessrc/skillspector/cli.py— Documentation of supported environment variables (lines 250-270)
Summary
- Set
SKILLSPECTOR_PROVIDERtoopenai,anthropic, orbedrockto select your backend. - Configure credentials via provider-specific variables:
OPENAI_API_KEY,ANTHROPIC_API_KEY, or standard AWS boto3 credentials for Bedrock. - Override default models using
SKILLSPECTOR_MODELand slot-specific variants likeSKILLSPECTOR_MODEL_META_ANALYZER. - Access providers programmatically through
get_chat_model()inskillspector.llm_utils. - SkillSpector falls back to OpenAI automatically if the selected provider fails to initialize.
Frequently Asked Questions
What happens if I don't set SKILLSPECTOR_PROVIDER?
SkillSpector defaults to the NVIDIA build provider. If that provider cannot be instantiated or if you lack NVIDIA-specific credentials, the system falls back to the standard OpenAI provider, provided OPENAI_API_KEY is available.
Can I use different models for different analysis tasks?
Yes. Set SKILLSPECTOR_MODEL_<SLOT> where <SLOT> is the analysis component name (e.g., META_ANALYZER). This allows you to use cheaper models for meta-analysis while running expensive models for primary semantic quality checks.
Does SkillSpector support custom OpenAI-compatible endpoints?
Yes. When using SKILLSPECTOR_PROVIDER=openai, set the OPENAI_BASE_URL environment variable to point to any OpenAI-compatible API endpoint, such as local LLM servers or proxy services.
Why doesn't Bedrock require an API key?
The Bedrock provider uses the AWS boto3 credential chain, which automatically sources credentials from environment variables, AWS profiles, EC2 instance metadata, or IAM roles. This approach aligns with AWS security best practices and eliminates the need for hardcoded API keys.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →