# Claude Code Third Party Providers

> Connect non-Anthropic LLMs to Claude Code via proxy.

- Skill: `wcpaka-lgtm/claude-code-third-party-providers` (Agent Skill, multi-file: 4 files)
- Install (CLI): `npx skillmds@latest add wcpaka-lgtm/claude-code-third-party-providers`
- Raw SKILL.md: https://api.skillmd.com/api/skills/wcpaka-lgtm/claude-code-third-party-providers/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- License: MIT
- Author: wcpaka-lgtm (https://skillmd.com/u/wcpaka-lgtm)
- Updated: 2026-09-21
- Page: https://skillmd.com/skills/wcpaka-lgtm/claude-code-third-party-providers

---


# Claude Code — Third-Party LLM Provider Connection

Connect OpenAI-compatible LLM APIs (Alibaba Qwen, DashScope, any `/v1/chat/completions` endpoint) to Claude Code, which only speaks the Anthropic Messages protocol.

## When to Use

- User wants to use a non-Anthropic model (Qwen, GLM, DeepSeek, etc.) inside Claude Code
- User has an OpenAI-compatible API key/endpoint and wants Claude Code as the coding agent
- Claude Code says "Not logged in" or "Invalid API key" when pointed at a non-Anthropic endpoint

## Core Problem

Claude Code **only** speaks the Anthropic Messages API format (`/v1/messages` with content blocks, tool_use, etc.). Setting `OPENAI_API_KEY`/`OPENAI_BASE_URL` does NOT work — Claude Code ignores them and demands Anthropic auth. Setting `ANTHROPIC_BASE_URL` to an OpenAI-compatible endpoint fails because the request/response formats differ.

## Solution: Local Translation Proxy

A lightweight Python proxy on localhost translates:
- **Inbound:** Anthropic Messages API (`POST /v1/messages`) from Claude Code
- **Outbound:** OpenAI Chat Completions API (`POST /v1/chat/completions`) to the provider

### Setup Steps

1. **Write the proxy** — use `templates/proxy.py` from this skill (copy to `~/claude-qwen-proxy/proxy.py`)
2. **Start the proxy:**
   ```bash
   export OPENAI_API_KEY="<provider-api-key>"
   export OPENAI_BASE_URL="<provider-base-url>"   # e.g. https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1
   python ~/claude-qwen-proxy/proxy.py
   # Listens on http://127.0.0.1:8082
   ```
3. **Run Claude Code through the proxy:**
   ```bash
   export ANTHROPIC_API_KEY="sk-proxy-placeholder"   # ANY non-empty string works
   export ANTHROPIC_BASE_URL="http://127.0.0.1:8082"
   claude --bare --model qwen3.8-max-preview -p "Say hello" --max-turns 1
   ```
4. **Verify** — should get a text response. If "Invalid API key" → ANTHROPIC_API_KEY not set. If "model not found" → check provider's `/v1/models` endpoint for exact model IDs.

### Windows Convenience Scripts

Create `start-proxy.bat` (sets OPENAI_* env vars, runs proxy.py) and `claude-qwen.bat` (sets ANTHROPIC_* env vars, runs claude). See `templates/` directory.

## Pitfalls

1. **ANTHROPIC_API_KEY must be set** — even to a dummy value. Without it, Claude Code enters OAuth login flow and ignores ANTHROPIC_BASE_URL.
2. **`--bare` flag is important** — skips OAuth/keychain reads, plugin sync, and CLAUDE.md discovery. Without it, Claude Code may try to validate the key against Anthropic's servers.
3. **litellm proxy is an alternative but often fails on Windows** — `pip install litellm` hits metadata generation errors. The custom proxy (stdlib-only, no deps) is more reliable.
4. **Model names must match the provider's `/v1/models` list exactly** — query it with `curl -H "Authorization: Bearer $KEY" $BASE_URL/models`.
5. **Streaming translation is imperfect** — tool_use blocks in streaming mode require stateful reassembly. The template proxy handles basic text streaming; complex multi-tool agentic loops may hit edge cases.
6. **Proxy must stay running** — it's a foreground process. Use `start-proxy.bat` in a minimized window or run under a process manager.
7. **Claude Code features that depend on Anthropic-specific APIs won't work** — e.g., extended thinking blocks, prompt caching headers, `/usage` command. Basic coding (read/write/bash) works fine.

## Verification Checklist

```bash
# 1. Provider endpoint reachable?
curl -s "$OPENAI_BASE_URL/models" -H "Authorization: Bearer $OPENAI_API_KEY" | head -5

# 2. Proxy running?
curl -s http://127.0.0.1:8082/   # → {"status": "ok", "proxy": "anthropic-to-openai"}

# 3. Claude Code connected?
ANTHROPIC_API_KEY=sk-placeholder ANTHROPIC_BASE_URL=http://127.0.0.1:8082 \
  claude --bare --model <model-id> -p "Say hello" --max-turns 1
```

## Known Working Providers

| Provider | Base URL | Models confirmed |
|----------|----------|-----------------|
| Alibaba Coding Plan | `https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1` | qwen3.8-max-preview, glm-5.2, deepseek-v4-pro |
| DashScope (general) | `https://dashscope.aliyuncs.com/compatible-mode/v1` | qwen-* series |

## Gap Note

The bundled `claude-code` skill (v2.2.1) does NOT cover third-party provider connection. Its auth section only documents Anthropic OAuth, ANTHROPIC_API_KEY for Anthropic, and Bedrock/Vertex/Foundry. If that skill is ever updated, this content should be merged into it.

