What is Claude Code?
Claude Code is Anthropic’s agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster through natural language commands. It serves as an intelligent pair programming partner that can read, analyze, and work with your entire project structure.Model Configuration
Claude Code supports model aliases (opus
, sonnet
, haiku
, opusplan
) that provide convenient shortcuts for different use cases. When integrating with TrueFoundry, you can configure these aliases to use your specific TrueFoundry models through environment variables.
Model aliases allow you to switch between different Claude models during your coding session using simple commands like
/model opus
or /model sonnet
.Prerequisites
Before integrating Claude Code with TrueFoundry, ensure you have:- TrueFoundry Account: Create a Truefoundry account with atleast one model provider and generate a Personal Access Token by following the instructions in Generating Tokens
- Claude Code Installation: Install Claude Code following the official documentation
- Configure models in Truefoundry for each provider you want to use
Integrate Truefoundry with Claude Code
Claude Code uses a settings.json file for configuration. You’ll need to modify the environment variables to route requests through Truefoundry. First, get the base URL and model name from your TrueFoundry AI Gateway playground using the unified code snippet (ensure you use the same model name as written):
Get Base URL and Model Name from Unified Code Snippet
- Global:
~/.claude/settings.json
- Project-specific:
.claude/settings.json
in your project directory
- Anthropic Direct API
- AWS Bedrock
- Google Vertex AI
your-truefoundry-api-key
with your TrueFoundry API keycontrolPlaneUrl
with your Control Plane URLprojectId
with your Google Project Idregion
with Region of the Model- Update the model name to match your configured TrueFoundry models
Using Claude Code VS Code Extension
The Claude Code VS Code extension works seamlessly with TrueFoundry once you’ve configured the CLI.The VS Code extension is not standalone. It requires the Claude Code CLI to be installed separately and configured first.
- Install and configure the Claude Code CLI as described above
- Install the VS Code extension
- Launch VS Code from your terminal to inherit the configuration:
The extension automatically uses your CLI configuration (base URL, API keys, model aliases). No separate setup needed.
Model Alias Configuration
The following environment variables map Claude Code’s built-in aliases to your TrueFoundry models:ANTHROPIC_DEFAULT_OPUS_MODEL
: Mapsopus
alias to your TrueFoundry Opus modelANTHROPIC_DEFAULT_SONNET_MODEL
: Mapssonnet
alias to your TrueFoundry Sonnet modelANTHROPIC_DEFAULT_HAIKU_MODEL
: Mapshaiku
alias to your TrueFoundry Haiku model
/model opus
or /model sonnet
, and optimized workflows by choosing the right model for each task.
Example Usage
Claude Agent SDK
The Claude Agent SDK is the successor to the Claude Code SDK, providing programmatic access to build custom AI agents with the same capabilities as Claude Code.The Claude Code SDK has been deprecated. If you’re using the old SDK, migrate to the Claude Agent SDK for continued support and new features.
Installation
Key Changes from Claude Code SDK
What changed: The SDK no longer reads from filesystem settings automatically. You must explicitly specify which settings to load. Manual setup required: You now need to explicitly load settings for:- Settings files (
.claude/settings.json
for project,~/.claude/settings.json
for user) CLAUDE.md
files (project memory)- Custom slash commands from
.claude/commands/
TrueFoundry Integration
Your existing.claude/settings.json
configuration works seamlessly with the Agent SDK. Simply specify setting_sources=["project"]
to load your TrueFoundry gateway configuration:
Anthropic Direct
, AWS Bedrock
, Google Vertex AI
) work identically with the Agent SDK.