Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 45 additions & 4 deletions src/langsmith/llm-gateway-coding-agents.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,26 @@ Claude Code supports two separate authentication methods. Choose one before conf

### Use a workspace provider secret

Set `ANTHROPIC_API_KEY` to your LangSmith API key. Claude Code reads these variables from your shell environment or from the `env` block in `~/.claude/settings.json`.
Set `ANTHROPIC_API_KEY` to your LangSmith API key. Claude Code reads these variables from your shell environment or from the `env` block in a settings file passed with `--settings`.

If your LangSmith deployment is on a regional or self-hosted instance, replace the gateway hostname in the examples below with your [regional gateway](/langsmith/llm-gateway-api-formats#use-a-regional-gateway) hostname.

#### Use Anthropic models only

Set `ANTHROPIC_BASE_URL` to the Anthropic-format gateway endpoint. The gateway infers the `anthropic/` provider prefix from the endpoint:
Set `ANTHROPIC_BASE_URL` to the Anthropic-format gateway endpoint. The gateway infers the `anthropic/` provider prefix from the endpoint.

**Use a settings file (recommended)**

```bash
touch ~/.claude/langsmith_gateway.settings.json
chmod "$(stat -f '%A' ~/.claude/settings.json)" ~/.claude/langsmith_gateway.settings.json
echo '{"env": {"ANTHROPIC_BASE_URL": "https://gateway.smith.langchain.com/anthropic/","ANTHROPIC_API_KEY": "YOUR_LANGSMITH_KEY_HERE"}}' > ~/.claude/langsmith_gateway.settings.json
claude --settings ~/.claude/langsmith_gateway.settings.json
```

Replace `YOUR_LANGSMITH_KEY_HERE` with your LangSmith API key.

**Use environment variables (fallback)**

```bash
export ANTHROPIC_BASE_URL="https://gateway.smith.langchain.com/anthropic/"
Expand All @@ -49,7 +62,20 @@ claude

#### Route model tiers across providers

Set `ANTHROPIC_BASE_URL` to the gateway root, then map each Claude model tier to a provider-prefixed gateway model ID:
Set `ANTHROPIC_BASE_URL` to the gateway root, then map each Claude model tier to a provider-prefixed gateway model ID.

**Use a settings file (recommended)**

```bash
touch ~/.claude/langsmith_gateway.settings.json
chmod "$(stat -f '%A' ~/.claude/settings.json)" ~/.claude/langsmith_gateway.settings.json
echo '{"env": {"ANTHROPIC_BASE_URL": "https://gateway.smith.langchain.com","ANTHROPIC_API_KEY": "YOUR_LANGSMITH_KEY_HERE","ANTHROPIC_DEFAULT_OPUS_MODEL": "anthropic/claude-opus-5","ANTHROPIC_DEFAULT_SONNET_MODEL": "openai/gpt-5.6-terra","ANTHROPIC_DEFAULT_HAIKU_MODEL": "fireworks/accounts/fireworks/models/glm-5p2"}}' > ~/.claude/langsmith_gateway.settings.json
claude --settings ~/.claude/langsmith_gateway.settings.json
```

Replace `YOUR_LANGSMITH_KEY_HERE` with your LangSmith API key.

**Use environment variables (fallback)**

```bash
export ANTHROPIC_BASE_URL="https://gateway.smith.langchain.com"
Expand All @@ -72,7 +98,22 @@ Claude subscription OAuth requires an active Claude Code Plus or Max subscriptio

Claude Code Plus and Max users can send their saved Anthropic OAuth credential through the gateway. This mode does not require an `ANTHROPIC_API_KEY` in workspace provider secrets.

Log in to Claude Code with your subscription, then configure the gateway:
Log in to Claude Code with your subscription, then configure the gateway.

#### Use a settings file (recommended)

Write the gateway configuration to a named settings file and pass it to Claude Code with `--settings`. This approach keeps your LangSmith API key out of your shell environment, shell history, and dotfiles:

```bash
touch ~/.claude/langsmith_gateway.settings.json
chmod "$(stat -f '%A' ~/.claude/settings.json)" ~/.claude/langsmith_gateway.settings.json
echo '{"env": {"ANTHROPIC_BASE_URL": "https://gateway.smith.langchain.com/anthropic","ANTHROPIC_CUSTOM_HEADERS": "X-Api-Key: YOUR_LANGSMITH_KEY_HERE"}}' > ~/.claude/langsmith_gateway.settings.json
claude --settings ~/.claude/langsmith_gateway.settings.json
```

Replace `YOUR_LANGSMITH_KEY_HERE` with your LangSmith API key.

#### Use environment variables (fallback)

```bash
export ANTHROPIC_BASE_URL="https://gateway.smith.langchain.com/anthropic"
Expand Down
Loading