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.Benefits of Using Truefoundry with Claude Code. With Truefoundry’s integration, you can enhance Claude Code with enterprise features:
  • Unified AI Gateway - Route Claude Code through multiple providers (Anthropic, Bedrock, Vertex AI)
  • Centralized Logs - Track all Claude Code interactions

Prerequisites

Before integrating Claude Code with TrueFoundry, ensure you have:
  1. TrueFoundry Account: Create a Truefoundry account with atleast one model provider and generate a Personal Access Token by following the instructions in Generating Tokens
  2. Claude Code Installation: Install Claude Code following the official documentation
  3. 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

Claude Code can be configured either globally or per project by editing the settings file:
  • Global: ~/.claude/settings.json
  • Project-specific: .claude/settings.json in your project directory
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://{controlPlaneUrl}/api/llm/v1",
    "ANTHROPIC_CUSTOM_HEADERS": "Authorization: Bearer your-truefoundry-api-key\nx-tfy-provider-name: <tfy-provider-name>",
    "ANTHROPIC_MODEL": "anthropic/claude-3-5"
  }
}
Replace:
  • your-truefoundry-api-key with your TrueFoundry API key
  • tfy-provider-name with the TrueFoundry Provider name
  • controlPlaneUrl with your Control Plane URL
  • projectId with your Google Project Id
  • region with Region of the Model
  • Update the model name if using a different Claude model

Using Claude Code

After configuring the settings file, you can use Claude Code as normal. The Truefoundry AI Gateway will handle routing your requests to the appropriate provider based on your configuration.

Example Commands

# Get help with a coding problem
claude "How do I implement a binary search tree in Python?"

# Generate a script
claude "Create a script that processes CSV files and extracts specific columns"

# Debug code
claude "Debug this function: def factorial(n): if n == 0: return 1 else: return n * factorial(n)"