Skip to content

Commit 4097042

Browse files
ericyangpanclaude
andcommitted
chore(docs): move CLAUDE.md to project root and add model-provider-setup skill
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 8429620 commit 4097042

File tree

3 files changed

+169
-0
lines changed

3 files changed

+169
-0
lines changed
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
---
2+
name: model-provider-setup
3+
description: Configure Claude Code to use alternative AI model providers by setting up custom API endpoints and authentication. Use this skill when users want to switch from default Anthropic models to providers like Z.AI, OpenRouter, or other custom endpoints with compatible APIs.
4+
---
5+
6+
# Model Provider Setup
7+
8+
## Overview
9+
10+
This skill configures `.claude/settings.local.json` to use alternative AI model providers that offer Anthropic-compatible APIs. It guides the setup of custom base URLs, model selections, and API authentication for providers beyond the default Anthropic service.
11+
12+
## When to Use This Skill
13+
14+
Use this skill when users:
15+
- Want to switch to alternative model providers (Z.AI, OpenRouter, etc.)
16+
- Need to configure custom API endpoints for Claude Code
17+
- Ask about setting up API keys for different providers
18+
- Request help configuring model provider settings
19+
20+
## Setup Workflow
21+
22+
### Step 1: Read Provider Configurations
23+
24+
Read the provider configurations from `references/providers.json` to understand available providers, their base URLs, and supported models.
25+
26+
The JSON structure contains:
27+
- Provider ID and display name
28+
- Description of the provider
29+
- Base URL for API requests
30+
- List of available models with IDs and descriptions
31+
32+
### Step 2: Present Provider Options to User
33+
34+
Use the `AskUserQuestion` tool to present available providers to the user. Structure the question as follows:
35+
36+
**Question format:**
37+
- Header: "Provider"
38+
- Question: "Which model provider would you like to configure?"
39+
- Options: Build from providers.json, using provider name as label and description as the option description
40+
- multiSelect: false (single provider selection)
41+
42+
### Step 3: Present Model Options for Selected Provider
43+
44+
After the user selects a provider, use `AskUserQuestion` again to let them choose a model from that provider's available models.
45+
46+
**Question format:**
47+
- Header: "Model"
48+
- Question: "Which model would you like to use?"
49+
- Options: Build from the selected provider's models array, using model name as label and description as the option description
50+
- multiSelect: false (single model selection)
51+
52+
### Step 4: Collect API Key
53+
54+
Use `AskUserQuestion` to collect the API key for the selected provider.
55+
56+
**Question format:**
57+
- Header: "API Key"
58+
- Question: "Please enter your API key for [provider name]:"
59+
- Options: Provide 2 options:
60+
- Label: "I'll enter my API key", Description: "Type or paste your API key in the 'Other' field below"
61+
- Label: "I'll add it manually later", Description: "Set up the configuration with a placeholder that you'll replace later"
62+
- multiSelect: false
63+
64+
**Important:** If the user selects "Other" and provides a custom text input, that is their API key. If they choose "I'll add it manually later", use the placeholder `"<YOUR_API_KEY_HERE>"`.
65+
66+
### Step 5: Update .claude/settings.local.json
67+
68+
Read the existing `.claude/settings.local.json` file if it exists. If it doesn't exist, create a new one.
69+
70+
Update or create the configuration with the following structure:
71+
72+
```json
73+
{
74+
"env": {
75+
"ANTHROPIC_BASE_URL": "<selected provider's baseUrl>",
76+
"ANTHROPIC_MODEL": "<selected model's id>",
77+
"ANTHROPIC_AUTH_TOKEN": "<user's API key or placeholder>"
78+
}
79+
}
80+
```
81+
82+
**Important considerations:**
83+
- Preserve any existing configuration in settings.local.json that is not related to these three env variables
84+
- Merge the new env variables with existing ones
85+
- Use proper JSON formatting with 2-space indentation
86+
87+
### Step 6: Confirm Setup
88+
89+
After updating the configuration file, inform the user:
90+
1. Which provider and model were configured
91+
2. The location of the settings file: `.claude/settings.local.json`
92+
3. If a placeholder was used, remind them to replace `<YOUR_API_KEY_HERE>` with their actual API key
93+
4. Note that they need to restart Claude Code for the changes to take effect
94+
95+
## Adding New Providers
96+
97+
To add new model providers to this skill, edit `references/providers.json` and add a new provider object with the following structure:
98+
99+
```json
100+
{
101+
"id": "unique-provider-id",
102+
"name": "Display Name",
103+
"description": "Brief description of the provider",
104+
"baseUrl": "https://api.example.com/v1",
105+
"models": [
106+
{
107+
"id": "model-identifier",
108+
"name": "Model Display Name",
109+
"description": "Brief description of the model"
110+
}
111+
]
112+
}
113+
```
114+
115+
## Resources
116+
117+
### references/providers.json
118+
119+
Contains the configuration database for all supported model providers. This file includes:
120+
- Provider metadata (ID, name, description)
121+
- API base URLs
122+
- Available models for each provider
123+
124+
This file should be read at the start of the workflow to populate the provider and model selection options.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"providers": [
3+
{
4+
"id": "zai",
5+
"name": "Z.AI (GLM Models)",
6+
"description": "China-based provider with GLM-4.7-coding and other GLM models",
7+
"baseUrl": "https://api.z.ai/api/anthropic",
8+
"models": [
9+
{
10+
"id": "glm-4.7-coding-preview",
11+
"name": "GLM-4.7 Coding Preview",
12+
"description": "Latest GLM coding model for enhanced code generation"
13+
},
14+
{
15+
"id": "glm-4-plus",
16+
"name": "GLM-4 Plus",
17+
"description": "Advanced general-purpose GLM model"
18+
}
19+
]
20+
},
21+
{
22+
"id": "openrouter",
23+
"name": "OpenRouter",
24+
"description": "Unified API gateway for multiple AI model providers",
25+
"baseUrl": "https://openrouter.ai/api/v1",
26+
"models": [
27+
{
28+
"id": "anthropic/claude-3.5-sonnet",
29+
"name": "Claude 3.5 Sonnet",
30+
"description": "Anthropic's Claude 3.5 Sonnet via OpenRouter"
31+
},
32+
{
33+
"id": "anthropic/claude-3-opus",
34+
"name": "Claude 3 Opus",
35+
"description": "Anthropic's most capable Claude 3 model via OpenRouter"
36+
},
37+
{
38+
"id": "openai/gpt-4-turbo",
39+
"name": "GPT-4 Turbo",
40+
"description": "OpenAI's GPT-4 Turbo via OpenRouter"
41+
}
42+
]
43+
}
44+
]
45+
}
File renamed without changes.

0 commit comments

Comments
 (0)