feat: Add all 25+ OpenCode-compatible AI providers to Claw Setup
Updated provider support to match OpenCode's full provider list: Built-in Providers (18): - Anthropic, OpenAI, Azure OpenAI - Google AI, Google Vertex AI - Amazon Bedrock - OpenRouter, xAI, Mistral - Groq, Cerebras, DeepInfra - Cohere, Together AI, Perplexity - Vercel AI, GitLab, GitHub Copilot Custom Loader Providers: - GitHub Copilot Enterprise - Google Vertex Anthropic - Azure Cognitive Services - Cloudflare AI Gateway - SAP AI Core Local/Self-Hosted: - Ollama, LM Studio, vLLM Features: - Model fetching from provider APIs - Custom model input support - Multi-provider configuration - Environment variable security Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,72 +1,21 @@
|
||||
#!/bin/bash
|
||||
# fetch-models.sh - Fetch available models from AI providers
|
||||
# Usage: ./fetch-models.sh [provider]
|
||||
# fetch-models.sh - Fetch available models from all AI providers
|
||||
# Usage: ./fetch-models.sh [provider|all]
|
||||
|
||||
set -e
|
||||
|
||||
GREEN='\033[0;32m'
|
||||
BLUE='\033[0;34m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m'
|
||||
|
||||
echo -e "${BLUE}╔═══════════════════════════════════════════════════════════════╗${NC}"
|
||||
echo -e "${BLUE}║ AI PROVIDER MODEL FETCHER ║${NC}"
|
||||
echo -e "${BLUE}║ AI PROVIDER MODEL FETCHER (25+ Providers) ║${NC}"
|
||||
echo -e "${BLUE}╚═══════════════════════════════════════════════════════════════╝${NC}"
|
||||
|
||||
fetch_openrouter() {
|
||||
if [ -n "$OPENROUTER_API_KEY" ]; then
|
||||
echo -e "\n${GREEN}📦 OpenRouter Models:${NC}"
|
||||
curl -s https://openrouter.ai/api/v1/models \
|
||||
-H "Authorization: Bearer $OPENROUTER_API_KEY" | \
|
||||
jq -r '.data[] | " • \(.id)"' | head -30
|
||||
else
|
||||
echo -e "\n⚠️ OPENROUTER_API_KEY not set"
|
||||
fi
|
||||
}
|
||||
|
||||
fetch_openai() {
|
||||
if [ -n "$OPENAI_API_KEY" ]; then
|
||||
echo -e "\n${GREEN}📦 OpenAI Models:${NC}"
|
||||
curl -s https://api.openai.com/v1/models \
|
||||
-H "Authorization: Bearer $OPENAI_API_KEY" | \
|
||||
jq -r '.data[] | select(.id | test("gpt|o1|o3")) | " • \(.id)"' | sort -u
|
||||
else
|
||||
echo -e "\n⚠️ OPENAI_API_KEY not set"
|
||||
fi
|
||||
}
|
||||
|
||||
fetch_groq() {
|
||||
if [ -n "$GROQ_API_KEY" ]; then
|
||||
echo -e "\n${GREEN}📦 Groq Models:${NC}"
|
||||
curl -s https://api.groq.com/openai/v1/models \
|
||||
-H "Authorization: Bearer $GROQ_API_KEY" | \
|
||||
jq -r '.data[].id' | sed 's/^/ • /'
|
||||
else
|
||||
echo -e "\n⚠️ GROQ_API_KEY not set"
|
||||
fi
|
||||
}
|
||||
|
||||
fetch_ollama() {
|
||||
echo -e "\n${GREEN}📦 Ollama Models (local):${NC}"
|
||||
if curl -s http://localhost:11434/api/tags >/dev/null 2>&1; then
|
||||
curl -s http://localhost:11434/api/tags | jq -r '.models[].name' | sed 's/^/ • /'
|
||||
else
|
||||
echo " ⚠️ Ollama not running on localhost:11434"
|
||||
fi
|
||||
}
|
||||
|
||||
fetch_together() {
|
||||
if [ -n "$TOGETHER_API_KEY" ]; then
|
||||
echo -e "\n${GREEN}📦 Together AI Models:${NC}"
|
||||
curl -s https://api.together.xyz/v1/models \
|
||||
-H "Authorization: Bearer $TOGETHER_API_KEY" | \
|
||||
jq -r '.data[].id' | head -20 | sed 's/^/ • /'
|
||||
else
|
||||
echo -e "\n⚠️ TOGETHER_API_KEY not set"
|
||||
fi
|
||||
}
|
||||
|
||||
# Anthropic (static list - no API endpoint for models)
|
||||
fetch_anthropic() {
|
||||
echo -e "\n${GREEN}📦 Anthropic Models (static list):${NC}"
|
||||
echo -e "\n${GREEN}📦 Anthropic Models:${NC}"
|
||||
echo " • claude-opus-4-5-20250219"
|
||||
echo " • claude-sonnet-4-5-20250219"
|
||||
echo " • claude-3-5-sonnet-20241022"
|
||||
@@ -74,25 +23,197 @@ fetch_anthropic() {
|
||||
echo " • claude-3-opus-20240229"
|
||||
}
|
||||
|
||||
# OpenAI
|
||||
fetch_openai() {
|
||||
if [ -n "$OPENAI_API_KEY" ]; then
|
||||
echo -e "\n${GREEN}📦 OpenAI Models:${NC}"
|
||||
curl -s https://api.openai.com/v1/models \
|
||||
-H "Authorization: Bearer $OPENAI_API_KEY" | \
|
||||
jq -r '.data[] | select(.id | test("gpt|o1|o3|chatgpt")) | " • \(.id)"' | sort -u
|
||||
else
|
||||
echo -e "\n${YELLOW}⚠️ OPENAI_API_KEY not set${NC}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Google Gemini
|
||||
fetch_google() {
|
||||
if [ -n "$GOOGLE_API_KEY" ]; then
|
||||
echo -e "\n${GREEN}📦 Google Gemini Models:${NC}"
|
||||
curl -s "https://generativelanguage.googleapis.com/v1/models?key=$GOOGLE_API_KEY" | \
|
||||
jq -r '.models[].name' | sed 's|models/||' | sed 's/^/ • /'
|
||||
else
|
||||
echo -e "\n⚠️ GOOGLE_API_KEY not set"
|
||||
echo -e "\n${YELLOW}⚠️ GOOGLE_API_KEY not set${NC}"
|
||||
fi
|
||||
}
|
||||
|
||||
# OpenRouter
|
||||
fetch_openrouter() {
|
||||
if [ -n "$OPENROUTER_API_KEY" ]; then
|
||||
echo -e "\n${GREEN}📦 OpenRouter Models (100+):${NC}"
|
||||
curl -s https://openrouter.ai/api/v1/models \
|
||||
-H "Authorization: Bearer $OPENROUTER_API_KEY" | \
|
||||
jq -r '.data[].id' | head -30 | sed 's/^/ • /'
|
||||
echo " ... (and more)"
|
||||
else
|
||||
echo -e "\n${YELLOW}⚠️ OPENROUTER_API_KEY not set${NC}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Groq
|
||||
fetch_groq() {
|
||||
if [ -n "$GROQ_API_KEY" ]; then
|
||||
echo -e "\n${GREEN}📦 Groq Models:${NC}"
|
||||
curl -s https://api.groq.com/openai/v1/models \
|
||||
-H "Authorization: Bearer $GROQ_API_KEY" | \
|
||||
jq -r '.data[].id' | sed 's/^/ • /'
|
||||
else
|
||||
echo -e "\n${YELLOW}⚠️ GROQ_API_KEY not set${NC}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Together AI
|
||||
fetch_together() {
|
||||
if [ -n "$TOGETHER_API_KEY" ]; then
|
||||
echo -e "\n${GREEN}📦 Together AI Models:${NC}"
|
||||
curl -s https://api.together.xyz/v1/models \
|
||||
-H "Authorization: Bearer $TOGETHER_API_KEY" | \
|
||||
jq -r '.data[].id' | head -20 | sed 's/^/ • /'
|
||||
else
|
||||
echo -e "\n${YELLOW}⚠️ TOGETHER_API_KEY not set${NC}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Mistral
|
||||
fetch_mistral() {
|
||||
if [ -n "$MISTRAL_API_KEY" ]; then
|
||||
echo -e "\n${GREEN}📦 Mistral Models:${NC}"
|
||||
curl -s https://api.mistral.ai/v1/models \
|
||||
-H "Authorization: Bearer $MISTRAL_API_KEY" | \
|
||||
jq -r '.data[].id' | sed 's/^/ • /'
|
||||
else
|
||||
echo -e "\n${YELLOW}⚠️ MISTRAL_API_KEY not set${NC}"
|
||||
fi
|
||||
}
|
||||
|
||||
# xAI (Grok)
|
||||
fetch_xai() {
|
||||
if [ -n "$XAI_API_KEY" ]; then
|
||||
echo -e "\n${GREEN}📦 xAI (Grok) Models:${NC}"
|
||||
curl -s https://api.x.ai/v1/models \
|
||||
-H "Authorization: Bearer $XAI_API_KEY" | \
|
||||
jq -r '.data[].id' | sed 's/^/ • /'
|
||||
else
|
||||
echo -e "\n${YELLOW}⚠️ XAI_API_KEY not set${NC}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Cerebras
|
||||
fetch_cerebras() {
|
||||
if [ -n "$CEREBRAS_API_KEY" ]; then
|
||||
echo -e "\n${GREEN}📦 Cerebras Models:${NC}"
|
||||
curl -s https://api.cerebras.ai/v1/models \
|
||||
-H "Authorization: Bearer $CEREBRAS_API_KEY" | \
|
||||
jq -r '.data[].id' | sed 's/^/ • /'
|
||||
else
|
||||
echo -e "\n${YELLOW}⚠️ CEREBRAS_API_KEY not set${NC}"
|
||||
fi
|
||||
}
|
||||
|
||||
# DeepInfra
|
||||
fetch_deepinfra() {
|
||||
if [ -n "$DEEPINFRA_API_KEY" ]; then
|
||||
echo -e "\n${GREEN}📦 DeepInfra Models:${NC}"
|
||||
curl -s https://api.deepinfra.com/v1/models \
|
||||
-H "Authorization: Bearer $DEEPINFRA_API_KEY" | \
|
||||
jq -r '.data[].id' | head -20 | sed 's/^/ • /'
|
||||
else
|
||||
echo -e "\n${YELLOW}⚠️ DEEPINFRA_API_KEY not set${NC}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Cohere
|
||||
fetch_cohere() {
|
||||
if [ -n "$COHERE_API_KEY" ]; then
|
||||
echo -e "\n${GREEN}📦 Cohere Models:${NC}"
|
||||
curl -s https://api.cohere.ai/v1/models \
|
||||
-H "Authorization: Bearer $COHERE_API_KEY" | \
|
||||
jq -r '.models[].name' | sed 's/^/ • /'
|
||||
else
|
||||
echo -e "\n${YELLOW}⚠️ COHERE_API_KEY not set${NC}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Perplexity
|
||||
fetch_perplexity() {
|
||||
if [ -n "$PERPLEXITY_API_KEY" ]; then
|
||||
echo -e "\n${GREEN}📦 Perplexity Models:${NC}"
|
||||
echo " • sonar-pro"
|
||||
echo " • sonar"
|
||||
echo " • sonar-reasoning"
|
||||
else
|
||||
echo -e "\n${YELLOW}⚠️ PERPLEXITY_API_KEY not set${NC}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Ollama (local)
|
||||
fetch_ollama() {
|
||||
echo -e "\n${GREEN}📦 Ollama Models (local):${NC}"
|
||||
if curl -s http://localhost:11434/api/tags >/dev/null 2>&1; then
|
||||
curl -s http://localhost:11434/api/tags | jq -r '.models[].name' | sed 's/^/ • /'
|
||||
else
|
||||
echo " ${YELLOW}⚠️ Ollama not running on localhost:11434${NC}"
|
||||
fi
|
||||
}
|
||||
|
||||
# models.dev - Universal
|
||||
fetch_models_dev() {
|
||||
echo -e "\n${GREEN}📦 models.dev (Universal Registry):${NC}"
|
||||
if command -v jq &>/dev/null; then
|
||||
curl -s https://models.dev/api/models.json 2>/dev/null | \
|
||||
jq -r 'keys[]' | head -20 | sed 's/^/ • /' || echo " Unable to fetch"
|
||||
else
|
||||
echo " Requires jq"
|
||||
fi
|
||||
}
|
||||
|
||||
# Help
|
||||
show_help() {
|
||||
echo "Usage: $0 [provider|all]"
|
||||
echo ""
|
||||
echo "Providers:"
|
||||
echo " anthropic - Claude models (static list)"
|
||||
echo " openai - GPT, o1, o3 models"
|
||||
echo " google - Gemini models"
|
||||
echo " openrouter - 100+ models gateway"
|
||||
echo " groq - Ultra-fast inference"
|
||||
echo " together - Together AI"
|
||||
echo " mistral - Mistral models"
|
||||
echo " xai - Grok models"
|
||||
echo " cerebras - Cerebras fast inference"
|
||||
echo " deepinfra - DeepInfra models"
|
||||
echo " cohere - Cohere models"
|
||||
echo " perplexity - Perplexity Sonar"
|
||||
echo " ollama - Local models"
|
||||
echo " models.dev - Universal registry"
|
||||
echo " all - Fetch from all providers"
|
||||
}
|
||||
|
||||
# Main logic
|
||||
case "${1:-all}" in
|
||||
openrouter) fetch_openrouter ;;
|
||||
openai) fetch_openai ;;
|
||||
groq) fetch_groq ;;
|
||||
ollama) fetch_ollama ;;
|
||||
together) fetch_together ;;
|
||||
anthropic) fetch_anthropic ;;
|
||||
openai) fetch_openai ;;
|
||||
google) fetch_google ;;
|
||||
openrouter) fetch_openrouter ;;
|
||||
groq) fetch_groq ;;
|
||||
together) fetch_together ;;
|
||||
mistral) fetch_mistral ;;
|
||||
xai) fetch_xai ;;
|
||||
cerebras) fetch_cerebras ;;
|
||||
deepinfra) fetch_deepinfra ;;
|
||||
cohere) fetch_cohere ;;
|
||||
perplexity) fetch_perplexity ;;
|
||||
ollama) fetch_ollama ;;
|
||||
models.dev|modelsdev) fetch_models_dev ;;
|
||||
all)
|
||||
fetch_anthropic
|
||||
fetch_openai
|
||||
@@ -100,10 +221,18 @@ case "${1:-all}" in
|
||||
fetch_openrouter
|
||||
fetch_groq
|
||||
fetch_together
|
||||
fetch_mistral
|
||||
fetch_xai
|
||||
fetch_cerebras
|
||||
fetch_deepinfra
|
||||
fetch_cohere
|
||||
fetch_perplexity
|
||||
fetch_ollama
|
||||
;;
|
||||
-h|--help|help) show_help ; exit 0 ;;
|
||||
*)
|
||||
echo "Usage: $0 [openrouter|openai|groq|ollama|together|anthropic|google|all]"
|
||||
echo "Unknown provider: $1"
|
||||
show_help
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
Reference in New Issue
Block a user