HomeDocsClaude Sonnet 4.5 API
Chat APIs

Claude Sonnet 4.5 API

Long-context reasoning with structured outputs, JSON mode, and enterprise safety controls for legal and technical workflows. · Updated 2025-03-18

Overview

Claude Sonnet 4.5 offers a 200K+ token window, robust reasoning mode, and built-in JSON formatting. It is ideal for summarising complex documents, drafting proposals, or performing policy-compliant analyses.

Basic Request

curl -X POST "https://api.transendai.net/v1/chat/claude-sonnet-4.5" \
  -H "Authorization: Bearer $TRANSEND_API_KEY" \
  -H "Content-Type": "application/json" \
  -d '{
    "mode": "reasoning",
    "messages": [
      { "role": "system", "content": "You are a technical proposal assistant." },
      { "role": "user", "content": "Summarise the attached RFP into pros, cons, and required integrations." }
    ],
    "response_format": {
      "type": "json_schema",
      "schema": {
        "type": "object",
        "properties": {
          "summary": { "type": "string" },
          "pros": { "type": "array", "items": { "type": "string" } },
          "cons": { "type": "array", "items": { "type": "string" } },
          "integrations": { "type": "array", "items": { "type": "string" } }
        },
        "required": ["summary"]
      }
    }
  }'

Attachments

Embed large documents using the documents field:

"documents": [
  { "type": "pdf", "url": "https://storage.example.com/rfp.pdf" }
]

You can provide up to 20 documents per request.

Response Excerpt

{
  "id": "chatcmpl_sonnet_731",
  "usage": { "prompt_tokens": 73280, "completion_tokens": 1480, "total_tokens": 74760 },
  "choices": [
    {
      "message": {
        "role": "assistant",
        "content": {
          "summary": "The vendor provides a turnkey multi-region deployment...",
          "pros": ["Native Kubernetes support", "Meets SOC2 Type II requirements"],
          "cons": ["Requires dedicated support contract"],
          "integrations": ["Okta SSO", "Datadog Metrics"]
        }
      }
    }
  ]
}

Safety Settings

Use safety_overrides to configure organisation policies:

"safety_overrides": {
  "disallowed_terms": ["confidential", "internal-only"],
  "escalate_email": "[email protected]"
}

Error Codes

CodeReasonAction
400JSON schema invalid or exceeds size limit.Reduce schema depth and ensure it is valid draft-07 JSON Schema.
413Context window exceeded.Trim documents or chunk them with a retrieval pipeline.
451Policy violation triggered.Review the returned policy_violation payload and adjust prompts.

Performance Tips

  • Enable stream: true for incremental JSON tokens during long completions.
  • Use retrieval-augmented generation (RAG) to dodge the 200K context limit when documents are extremely large.
  • Capture trace_id for every call to correlate with logs in the observability dashboard.

Related Links