# Connect Claude Code to MandAPI

Configure the Anthropic-compatible endpoint, choose a supported model and check your first coding session.

## What you will set up

Claude Code runs on your computer and sends model requests through MandAPI. This guide covers the command-line tool. The Claude desktop application has a different gateway setup. For a managed Windows setup, you can use [MandAPI Connect](/en/connect).

Install Claude Code using its current official installation guide. Create a MandAPI key from your [dashboard](https://app.mandapi.com/console), and choose an account-visible model that supports the Anthropic Messages format and the coding features you need. Replace `MODEL_ID` below with that exact model ID. A model appearing in a catalog does not establish every tool capability.

## Set the connection for one terminal session

The Anthropic-compatible base address is `https://api.mandapi.com`. Claude Code adds its Messages path. Start with session-scoped settings so you can check the connection before making it permanent.

Bash:

```bash
export ANTHROPIC_BASE_URL="https://api.mandapi.com"
read -rsp "MandAPI key: " ANTHROPIC_AUTH_TOKEN
printf '\n'
export ANTHROPIC_AUTH_TOKEN
unset ANTHROPIC_API_KEY
claude --model MODEL_ID
```

PowerShell:

```powershell
$env:ANTHROPIC_BASE_URL = 'https://api.mandapi.com'
$env:ANTHROPIC_AUTH_TOKEN = [Net.NetworkCredential]::new('', (Read-Host 'MandAPI key' -AsSecureString)).Password
Remove-Item Env:ANTHROPIC_API_KEY -ErrorAction SilentlyContinue
claude --model MODEL_ID
```

Keep the credential in your own environment or secret store. A shared project settings file should contain instructions, not your real key. Session variables disappear when you close that terminal.

## Check the first session

Open a small project, start Claude Code and run `/status` to inspect its active connection. Ask: “Read the README and summarize this project in three sentences. Do not change files.” Check that a normal answer arrives, then inspect the corresponding usage in your MandAPI dashboard. This tests a small text task; test your required tool actions separately before using a large project.

## Fix connection problems

If authentication fails, check that the launched terminal inherited `ANTHROPIC_AUTH_TOKEN` and that the key is active. Check presence without printing the value. If the model or route is missing, recheck the exact model ID and the base address: this Claude Code configuration uses the host without a `/v1` suffix. Restart the tool after changing its environment. Keep your normal permission confirmations enabled.

## Finish or restore the previous session

Close the configured terminal to discard these session settings. To continue in the same Bash session, unset the two `ANTHROPIC_` variables; in PowerShell, remove them from `Env:`. A saved personal Claude login is separate from the MandAPI key. Reopen your normal terminal to return to its usual setup.

## References

- [https://code.claude.com/docs/en/llm-gateway-connect](https://code.claude.com/docs/en/llm-gateway-connect)
- [https://mandapi.com/en/connect](https://mandapi.com/en/connect)
- [https://mandapi.com/es/connect](https://mandapi.com/es/connect)
