# TheClaudeAPI setup for Windows PowerShell # Usage: irm https://aisoftdeal.com/setup.ps1 | iex function Install-TheClaudeAPI { $ErrorActionPreference = "Stop" [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 $Base = "https://aisoftdeal.com/api/public" $StatusUrl = "https://aisoftdeal.com/api/public/v1/key-status" Write-Host "" Write-Host "== TheClaudeAPI setup ==" -ForegroundColor Cyan $Key = $env:THECLAUDEAPI_KEY if (-not $Key) { $Key = Read-Host "Enter your API key (sk-...)" } $Key = ($Key -replace "\s", "") # Only letters, digits, "-" and "_" are allowed, so the key is safe to write into JSON and env vars. if ($Key -cnotmatch '^(sk|kx)-[A-Za-z0-9_-]{10,200}$') { Write-Host "Error: invalid key format. Paste the full key starting with sk-" -ForegroundColor Red; return } Write-Host "Checking your key..." try { $s = Invoke-RestMethod -Uri $StatusUrl -Headers @{ "x-api-key" = $Key } -UseBasicParsing } catch { Write-Host "Key check failed: $($_.Exception.Message)" -ForegroundColor Red; return } if ($s.status -ne "active") { Write-Host "Key is not active (status: $($s.status))" -ForegroundColor Red; return } Write-Host "Key OK. Plan: $($s.plan)" -ForegroundColor Green $Dir = Join-Path $HOME ".claude" $File = Join-Path $Dir "settings.json" New-Item -ItemType Directory -Force -Path $Dir | Out-Null if (Test-Path $File) { Copy-Item $File "$File.bak" -Force; Write-Host "Backed up old settings.json" } $Json = @" { "env": { "ANTHROPIC_AUTH_TOKEN": "$Key", "ANTHROPIC_BASE_URL": "$Base", "ANTHROPIC_MODEL": "anthropic/claude-sonnet-5.5", "ANTHROPIC_SMALL_FAST_MODEL": "anthropic/claude-haiku-5.5", "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1" }, "hasCompletedOnboarding": true } "@ # UTF-8 without BOM (a BOM breaks JSON parsing in Claude Code) [IO.File]::WriteAllText($File, $Json, (New-Object System.Text.UTF8Encoding($false))) Write-Host "Wrote $File" foreach ($pair in @( @("ANTHROPIC_BASE_URL", $Base), @("ANTHROPIC_AUTH_TOKEN", $Key), @("OPENAI_BASE_URL", "$Base/v1"), @("OPENAI_API_KEY", $Key))) { [Environment]::SetEnvironmentVariable($pair[0], $pair[1], "User") Set-Item -Path ("Env:" + $pair[0]) -Value $pair[1] } Write-Host "Saved environment variables." Write-Host "" Write-Host "Done. Open a NEW PowerShell window (or restart VS Code) and run: claude" -ForegroundColor Green } Install-TheClaudeAPI