Mafdet AI Help Center中文

Claude Code setup

Claude Code (Anthropic's CLI coding agent) speaks the Anthropic protocol. The Mafdet AI gateway serves it natively on /v1/messages, so Claude Code works by setting environment variables only — no config file changes.

Configuration

Add to your shell profile (or run in a terminal), then start claude:

export ANTHROPIC_BASE_URL="https://api.mafdet.ai"
export ANTHROPIC_AUTH_TOKEN="sk-mafdet-xxxxxxxxxxxxxxxx"
export ANTHROPIC_MODEL="deepseek-v4-pro"
export ANTHROPIC_SMALL_FAST_MODEL="deepseek-v4-flash"
claude
  • ANTHROPIC_BASE_URL must not include /v1 — Claude Code appends /v1/messages itself
  • ANTHROPIC_AUTH_TOKEN is your Mafdet AI key (prefer an environment variable over pasting it into files)
  • ANTHROPIC_MODEL is a Mafdet AI model ID (see Models overview); coding-capable models such as the DeepSeek V4 or Kimi families work best
  • ANTHROPIC_SMALL_FAST_MODEL handles Claude Code's lightweight background calls — a cheap fast model keeps costs down

You can also generate this snippet pre-filled with your model from Console → API Keys → Developer Tools. Usage over /v1/messages is billed the same way as the OpenAI-compatible endpoint.

Common errors

SymptomMeaningFix
401Wrong key or bad formatCheck ANTHROPIC_AUTH_TOKEN
404Base URL includes /v1Use https://api.mafdet.ai (no /v1)
429Rate limited (RPM/TPM)Coding agents need a key with a high TPM limit
insufficient_creditOut of balanceSee Balance & usage

Next steps