Refined Custom Preset
Battle-tested setting for custom, headers, requests, specialized. Includes structured workflows, validation checks, and reusable patterns for api.
Refined Custom Preset
Fully customizable Claude Code API preset that allows granular control over model routing, token limits, and endpoint configuration.
When to Use This Setting
Apply this setting when you need to:
- Connect Claude Code to a custom API endpoint such as a self-hosted proxy or third-party gateway
- Override default model parameters including temperature, max tokens, and system prompts at the API level
- Create a reusable API configuration that can be shared across team members via version control
Consider alternatives when:
- Standard Anthropic, Bedrock, or Vertex configurations already meet your API routing needs
- You require only model selection changes without custom endpoint routing
Quick Start
Configuration
name: refined-custom-preset type: setting category: api
Example Application
claude setting:apply refined-custom-preset
Example Output
Setting applied successfully. Configuration changes:
- ANTHROPIC_BASE_URL: custom endpoint configured
- ANTHROPIC_MODEL: custom model set
- Token limits: adjusted per configuration
Core Concepts
Custom API Routing Overview
| Aspect | Details |
|---|---|
| Endpoint | Any OpenAI-compatible or Anthropic API |
| Authentication | API key, bearer token, or custom header |
| Model Override | Full model ID customization |
| Rate Limiting | Configurable per-endpoint thresholds |
| Fallback | Optional secondary endpoint on failure |
Custom Preset Architecture
ββββββββββββββββ ββββββββββββββββββββ
β Claude Code β β Custom Endpoint β
β βββββ>β ββββββββββββββ β
β Settings: β β β Auth Layer β β
β - base_url β β βββββββ¬βββββββ β
β - model β β βββββββ΄βββββββ β
β - tokens β β β Model Routeβ β
β β β βββββββ¬βββββββ β
ββββββββββββββββ β βββββββ΄βββββββ β
β β Response β β
β ββββββββββββββ β
ββββββββββββββββββββ
Configuration
| Parameter | Type | Default | Description |
|---|---|---|---|
| ANTHROPIC_BASE_URL | string | api.anthropic.com | Custom API endpoint URL |
| ANTHROPIC_AUTH_TOKEN | string | none | Authentication token for custom endpoint |
| ANTHROPIC_MODEL | string | claude-sonnet-4-5 | Primary model identifier for requests |
| ANTHROPIC_SMALL_FAST_MODEL | string | claude-3-5-haiku | Secondary model for fast operations |
| MAX_OUTPUT_TOKENS | string | 16384 | Maximum tokens per response from endpoint |
Best Practices
-
Validate Endpoint Compatibility - Before applying the preset, send a test request to your custom endpoint using curl to confirm it accepts the Anthropic message format. Incompatible endpoints will cause silent failures or malformed responses.
-
Use Environment Variable References - Store sensitive values like API keys as environment variable references rather than hardcoded strings. This prevents credentials from being committed to version control when sharing preset files.
-
Configure Sensible Token Limits - Set max output tokens based on your endpoint's capabilities and your billing constraints. Custom endpoints may have different token limits than the standard Anthropic API, and exceeding them causes truncated responses.
-
Implement Health Checks - Add a lightweight health check script that runs before each session to verify the custom endpoint is reachable. This provides clear error messages instead of cryptic timeout failures during coding sessions.
-
Document Model Mappings - When your custom endpoint uses different model identifiers than Anthropic's standard naming, maintain a mapping document. This helps team members understand which underlying model they are using and its capability differences.
Common Issues
-
Authentication format mismatch - Custom endpoints may expect different auth header formats (Bearer vs x-api-key). Check your endpoint documentation and adjust the ANTHROPIC_AUTH_TOKEN format accordingly.
-
Streaming not supported - Some proxy endpoints do not support server-sent events for streaming. If responses appear to hang, check whether your endpoint supports streaming and disable it if necessary.
-
Model ID not recognized - Custom endpoints may use different model naming conventions. Verify the exact model identifier string your endpoint expects and update ANTHROPIC_MODEL to match precisely.
Reviews
No reviews yet. Be the first to review this template!
Similar Templates
Project Standards Config
Claude Code settings preset that enforces consistent coding standards. Configures TypeScript strict mode, ESLint rules, Prettier formatting, and naming conventions.
Bedrock Configuration Blueprint
All-in-one setting covering configure, claude, code, amazon. Includes structured workflows, validation checks, and reusable patterns for api.
Refined Corporate Preset
Production-ready setting that handles configure, proxy, settings, corporate. Includes structured workflows, validation checks, and reusable patterns for api.