{"uid":"cap_JobDqlWd-62Cy-zw8ni1x","slug":"x402-gateway-production-up-railway-app-c928ddff","name":"Devstral Code LLM via x402 Gateway","description":"Mistral's code-focused model — optimized for software development and technical tasks","url":"https://x402-gateway-production.up.railway.app/api/llm/devstral","method":"POST","headers":{},"bodySchema":null,"responseSchema":null,"example":{"request":{"messages":[{"role":"user","content":"Write a Python function that validates email addresses using regex and returns True if valid, False otherwise. Include error handling for edge cases."}]},"response":{"model":"mistralai/devstral-2512","usage":{"cost":0.0011976,"is_byok":false,"cost_details":{"upstream_inference_cost":0.0011976,"upstream_inference_prompt_cost":0.0000116,"upstream_inference_completions_cost":0.001186},"total_tokens":622,"prompt_tokens":29,"completion_tokens":593,"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":"# Python Function to Validate Email Addresses Using Regex\n\nHere's a Python function that validates email addresses using regular expressions with proper error handling:\n\n```python\nimport re\n\ndef validate_email(email):\n    \"\"\"\n    Validates an email address using regex pattern matching.\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    Raises:\n        TypeError: If the input is not a string\n    \"\"\"\n    # Error handling for non-string inputs\n    if not isinstance(email, str):\n        raise TypeError(\"Input must be a string\")\n\n    # Empty string check\n    if not email:\n        return False\n\n    # Regular expression pattern for email validation\n    pattern = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$'\n\n    try:\n        # Compile the regex pattern\n        regex = re.compile(pattern)\n\n        # Check if the email matches the pattern\n        if regex.fullmatch(email):\n            return True\n        return False\n\n    except re.error:\n        # Handle potential regex compilation errors\n        return False\n```\n\n## Explanation:\n\n1. **Error Handling**:\n   - Checks if input is a string (raises TypeError if not)\n   - Handles empty strings by returning False\n   - Catches potential regex compilation errors\n\n2. **Regex Pattern**:\n   - `^[a-zA-Z0-9._%+-]+` - Local part (before @) allows letters, numbers, and certain special characters\n   - `@` - The @ symbol\n   - `[a-zA-Z0-9.-]+` - Domain name (after @) allows letters, numbers, dots, and hyphens\n   - `\\.[a-zA-Z]{2,}$` - Top-level domain (after last dot) must be at least 2 letters\n\n3. **Validation**:\n   - Uses `fullmatch()` to ensure the entire string matches the pattern\n   - Returns True for valid emails, False otherwise\n\n## Example Usage:\n\n```python\n# Valid emails\nprint(validate_email(\"user@example.com\"))  # True\nprint(validate_email(\"first.last@sub.domain.co.uk\"))  # True\n\n# Invalid emails\nprint(validate_email(\"user@.com\"))  # False\nprint(validate_email(\"user@com\"))  # False\nprint(validate_email(\"user@com.\"))  # False\n\n# Edge cases\nprint(validate_email(\"\"))  # False\ntry:\n    print(validate_email(123))  # Raises TypeError\nexcept TypeError as e:\n    print(e)  # \"Input must be a string\"\n```\n\nThis function provides robust email validation while handling common edge cases and potential errors."}},"exampleRequest":{"messages":[{"role":"user","content":"Write a Python function that validates email addresses using regex and returns True if valid, False otherwise. Include error handling for edge cases."}]},"tags":["x402"],"displayCostAmount":"0.020000","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"settled","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.020000/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.02","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.02","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_vIDFoIP7byYgx3YAlc_Pu","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.02","costPer":"request","priority":0,"asset":null,"unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Runs Mistral's Devstral code-focused language model, optimized for software development and technical tasks, accessible via x402 micropayment protocol","exampleAgentPrompt":"Write me a Python function that parses a CSV file and returns a list of dicts, with error handling for malformed rows — use Devstral since this is a coding task.","exampleUseCases":null,"resultDescription":"A text response containing generated code, code explanations, debugging suggestions, or technical answers produced by Mistral's Devstral model, which is specifically fine-tuned for software development tasks.","failureModes":["Invalid or missing prompt body returns 400 error","Payment not provided or insufficient USDC returns 402 payment required","Model overload or upstream Mistral API unavailability returns 503","Malformed JSON request body returns 400","Prompt too long exceeding model context window returns 413 or error message"],"whenToPreferThis":"Choose this endpoint when the task is primarily code-related — writing, debugging, explaining, or refactoring code — and you want a model specifically optimized for software development rather than a general-purpose LLM. Prefer over GPT-4o or Claude if cost-sensitivity matters and the task is purely technical coding work. The x402 micropayment at $0.02 USDC per call makes it suitable for high-volume programmatic code generation workflows.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":1,"lastUsedAt":"2026-05-20T10:10:13.183Z","lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-15T06:33:00.358Z","isFirstParty":false}