#!/usr/bin/env python3 """LEGACY Text Completions (POST /v1/complete) via raw HTTP. STATUS: LEGACY + DEPRECATED + FAILED_VERIFICATION 2026-09-18 — the API returns 400 invalid_request_error "The /v1/complete endpoint has been deprecated. Please use the /v1/messages endpoint instead." anthropic 1.7.0 no longer has `client.completions` (removed in v1), so this uses scripts/live.py. Run: .venv/bin/python examples/anthropic/messages/legacy_complete.py """ import json import sys from pathlib import Path sys.path.insert(0, str(Path(__file__).resolve().parents[3])) from scripts.live import anthropic_request, mask # noqa: E402 st, body, _ = anthropic_request("POST", "/v1/complete", {"model": "claude-2.1", "max_tokens_to_sample": 8, "prompt": "\n\nHuman: Reply with OK.\n\nAssistant:"}, note="example legacy_complete.py") print("HTTP", st, mask(json.dumps(body)))