Claude Code
Use XiaoYuan AI with Claude Code CLI, Desktop App, or IDE extensions.
Prerequisites
- Claude Code installed (Download here)
- API key from https://ai.xiaoyuan.co.uk
Configuration
Claude Code can be configured to use custom API endpoints through the settings.
Method 1: Using Claude Code Settings (Recommended)
- Open Claude Code
- Type
/configor access settings - Navigate to API settings
- Configure:
- API Base URL:
https://ai.xiaoyuan.co.uk/v1 - API Key: Your XiaoYuan API key
- Model:
claude-opus-4-8
- API Base URL:
Method 2: Manual Configuration File
Edit the Claude Code settings file directly:
json
{
"api": {
"baseUrl": "https://ai.xiaoyuan.co.uk/v1",
"apiKey": "your-api-key-here",
"defaultModel": "claude-opus-4-8"
}
}json
{
"api": {
"baseUrl": "https://ai.xiaoyuan.co.uk/v1",
"apiKey": "${XIAOYUAN_API_KEY}",
"defaultModel": "claude-opus-4-8"
}
}Method 3: Environment Variables
Set environment variables before launching Claude Code:
bash
export ANTHROPIC_API_KEY="your-xiaoyuan-api-key"
export ANTHROPIC_BASE_URL="https://ai.xiaoyuan.co.uk/v1"Then launch Claude Code:
bash
claudeUsage
Once configured, Claude Code will automatically use the XiaoYuan AI endpoint:
bash
# Start a conversation
claude chat
# Run in a project directory
cd /path/to/your/project
claude
# Use specific model
claude --model claude-opus-4-8Desktop App
For Claude Code Desktop:
- Open Preferences / Settings
- Navigate to API Configuration
- Set:
- Base URL:
https://ai.xiaoyuan.co.uk/v1 - API Key: Your XiaoYuan API key
- Base URL:
- Click Save and restart the app
IDE Extensions
VS Code
- Install the Claude Code extension
- Open VS Code settings (
Cmd/Ctrl + ,) - Search for "Claude Code"
- Configure:json
{ "claudeCode.api.baseUrl": "https://ai.xiaoyuan.co.uk/v1", "claudeCode.api.apiKey": "your-api-key-here", "claudeCode.model": "claude-opus-4-8" }
JetBrains IDEs
- Install the Claude Code plugin
- Open Settings → Tools → Claude Code
- Set:
- API Base URL:
https://ai.xiaoyuan.co.uk/v1 - API Key: Your XiaoYuan API key
- Model:
claude-opus-4-8
- API Base URL:
Verification
Test your configuration:
bash
claude --version
claude chat "Hello! Are you using Claude 4.8?"You should see responses from Claude Opus 4.8.
Troubleshooting
Connection Issues
If Claude Code can't connect:
- Verify the base URL is exactly:
https://ai.xiaoyuan.co.uk/v1 - Check your API key is valid
- Test the endpoint with curl:
bash
curl https://ai.xiaoyuan.co.uk/v1/models \
-H "Authorization: Bearer your-api-key-here"Model Not Found
Ensure you're using one of these model names:
claude-opus-4-8claude-opus-4.8claude-opus-4-latest
Authentication Errors
- Double-check your API key
- Ensure there are no extra spaces in the configuration
- Try regenerating your API key at https://ai.xiaoyuan.co.uk
Advanced Usage
Project-Specific Configuration
Create .claude/settings.json in your project:
json
{
"api": {
"baseUrl": "https://ai.xiaoyuan.co.uk/v1",
"apiKey": "${XIAOYUAN_API_KEY}",
"defaultModel": "claude-opus-4-8"
},
"projectContext": {
"name": "My Project",
"description": "Using XiaoYuan AI"
}
}Using with MCP Servers
Claude Code's Model Context Protocol (MCP) works seamlessly with XiaoYuan AI:
json
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@anthropic-ai/server-filesystem", "/path/to/project"]
}
},
"api": {
"baseUrl": "https://ai.xiaoyuan.co.uk/v1",
"apiKey": "your-api-key-here"
}
}Support
If you encounter issues:
- Check the API Key guide
- Review Claude Code documentation
- Contact XiaoYuan AI support