{"uid":"cap_wHleA_oGJQoAmnJGqwRtQ","slug":"x402-gateway-production-up-railway-app-2269cf55","name":"Claude Sonnet 4.6 via x402 Gateway","description":"Anthropic's latest balanced model — excellent coding, reasoning, and creative writing","url":"https://x402-gateway-production.up.railway.app/api/llm/claude-sonnet-4.6","method":"POST","headers":{},"bodySchema":null,"responseSchema":null,"example":{"request":{"model":"claude-sonnet-4.6","messages":[{"role":"user","content":"Write a Python function that validates email addresses using regex and returns True if valid, False otherwise. Include docstring and basic test cases."}],"max_tokens":1024},"response":{"model":"anthropic/claude-4.6-sonnet-20260217","usage":{"cost":0.015462,"is_byok":false,"cost_details":{"upstream_inference_cost":0.015462,"upstream_inference_prompt_cost":0.000102,"upstream_inference_completions_cost":0.01536},"total_tokens":1058,"prompt_tokens":34,"completion_tokens":1024,"prompt_tokens_details":{"audio_tokens":0,"video_tokens":0,"cached_tokens":0,"cache_write_tokens":0},"completion_tokens_details":{"audio_tokens":0,"image_tokens":0,"reasoning_tokens":0}},"content":"# Email Address Validator\n\n## Implementation\n\n```python\nimport re\n\n\ndef validate_email(email: str) -> bool:\n    \"\"\"\n    Validate an email address using regex.\n\n    An email is considered valid if it follows the standard format:\n    - Local part: alphanumeric characters, dots, underscores, plus signs, hyphens\n    - @ symbol (required, exactly one)\n    - Domain: alphanumeric characters and hyphens\n    - At least one dot in the domain part\n    - TLD: 2-7 alphabetic characters (e.g., .com, .org, .museum)\n\n    Args:\n        email (str): The email address to validate.\n\n    Returns:\n        bool: True if the email is valid, False otherwise.\n\n    Examples:\n        >>> validate_email(\"user@example.com\")\n        True\n        >>> validate_email(\"invalid-email\")\n        False\n        >>> validate_email(\"\")\n        False\n    \"\"\"\n    if not isinstance(email, str) or not email:\n        return False\n\n    pattern = r'^[a-zA-Z0-9][a-zA-Z0-9._%+\\-]*@[a-zA-Z0-9\\-]+(\\.[a-zA-Z0-9\\-]+)*\\.[a-zA-Z]{2,7}$'\n\n    return bool(re.match(pattern, email))\n\n\ndef run_tests() -> None:\n    \"\"\"Run test cases to verify the validate_email function.\"\"\"\n\n    test_cases = [\n        # (email, expected_result, description)\n\n        # ✅ Valid emails\n        (\"user@example.com\",           True,  \"Standard email\"),\n        (\"user.name@example.com\",      True,  \"Dot in local part\"),\n        (\"user+tag@example.com\",       True,  \"Plus sign in local part\"),\n        (\"user_name@example.com\",      True,  \"Underscore in local part\"),\n        (\"user123@example.com\",        True,  \"Numbers in local part\"),\n        (\"user@sub.example.com\",       True,  \"Subdomain\"),\n        (\"user@example.co.uk\",         True,  \"Country-code TLD\"),\n        (\"user@example.museum\",        True,  \"Long TLD\"),\n        (\"user-name@example.com\",      True,  \"Hyphen in local part\"),\n        (\"123user@example.com\",        True,  \"Starts with number\"),\n        (\"USER@EXAMPLE.COM\",           True,  \"All uppercase\"),\n        (\"user@my-domain.com\",         True,  \"Hyphen in domain\"),\n\n        # ❌ Invalid emails\n        (\"\",                           False, \"Empty string\"),\n        (\"plainaddress\",               False, \"No @ symbol\"),\n        (\"@missinglocal.com\",          False, \"Missing local part\"),\n        (\"user@\",                      False, \"Missing domain\"),\n        (\"user@.com\",                  False, \"Domain starts with dot\"),\n        (\"user@com\",                   False, \"No dot in domain\"),\n        (\"user@@example.com\",          False, \"Double @ symbol\"),\n        (\"user @example.com\",          False, \"Space in email\"),\n        (\"user@example..com\",          False, \"Double dot in domain\"),\n        (\"user@example.c\",             False, \"TLD too short (1 char)\"),\n        (\"user@example.toolongtld\",    False, \"TLD too long (>7 chars)\"),\n        (\".user@example.com\",          False, \"Starts with dot\"),\n        (\"user@-example.com\",          False, \"Domain starts with hyphen\"),\n        (None,                         False, \"None input\"),\n        (12345,                        False, \"Integer input\"),\n    ]\n\n    passed = 0\n    failed = 0\n\n    print(\"=\" * 65)\n    print(f\"{'EMAIL VALIDATION TEST RESULTS':^65}\")\n    print(\"=\" * 65)\n    print(f\"{'Email':<35} {'Expected':<10} {'Got':<10} {'Status'}\")\n    print(\"-\" * 65)\n\n    for email, expected, description in test_cases:\n        result = validate_email(email)\n        status = \"✅ PASS\" if result == expected else \"❌"}},"exampleRequest":{"model":"claude-sonnet-4.6","messages":[{"role":"user","content":"Write a Python function that validates email addresses using regex and returns True if valid, False otherwise. Include docstring and basic test cases."}],"max_tokens":1024},"tags":["x402"],"displayCostAmount":"0.060000","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"settled","requiresHandshake":false,"reviewCount":2,"rating":{"score":"0.50","successRate":"0.71","reviews":2,"stars":"3.0","state":"rated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.060000/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.06","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.06","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_Jh-kp3tLORR_mdsqrRv3V","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.06","costPer":"request","priority":0,"asset":null,"unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Calls Anthropic's Claude Sonnet 4.6 model for balanced high-quality coding, reasoning, and creative writing tasks via a pay-per-call x402 gateway","exampleAgentPrompt":"Write me a Python function that parses a JSON file and returns a summary of its top-level keys and value types — use Claude Sonnet for this since it's great at coding tasks.","exampleUseCases":null,"resultDescription":"A generated text response from Claude Sonnet 4.6 containing the model's answer, code, analysis, or creative output based on the input prompt, billed at $0.06 USDC per call via x402 protocol.","failureModes":["Payment not processed — x402 payment required before response is returned","Invalid or malformed prompt payload — returns 400 error","Model overload or upstream Anthropic API error — returns 503 or timeout","Insufficient USDC balance — payment failure blocks the call","Rate limiting from gateway — returns 429 if usage quota exceeded"],"whenToPreferThis":"Choose this endpoint when you need Anthropic's Claude Sonnet 4.6 specifically — Anthropic's balanced model known for strong coding, reasoning, and creative writing — and want pay-per-call pricing via x402 without a direct Anthropic API subscription. Prefer over Claude Opus when cost efficiency matters and over lighter models when task complexity demands strong reasoning. Prefer over GPT-4o or Gemini Flash when Claude's particular strengths in nuanced coding or extended reasoning are desired.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":42,"lastUsedAt":"2026-06-27T20:16:34.094Z","lastSuccessfullyRanAt":"2026-06-20T18:45:44.673Z","lastHealthCheckAt":"2026-09-13T12:49:40.183Z","isFirstParty":false}