concept
Claude integration design
Basic Messages request; inspect typed blocks and stop reason. Check approved model and SDK. Example is an offline text-only adapter.
Formal Syntax & Structure
artificial-intelligence syntaxartificial-intelligence
client.messages.create(model=..., max_tokens=..., system=..., messages=...)Working Example
Example Snippetartificial-intelligence
def route_text(message): # Only complete, ordinary text-only replies are accepted here. if message["stop_reason"] != "end_turn": return None blocks = message["content"] if not blocks or any(b["type"] != "text" for b in blocks): return None result = "".join(b["text"] for b in blocks) return result if result.strip() else None
print(route_text({"stop_reason": "end_turn", "content": [ {"type": "text", "text": "Blue "}, {"type": "text", "text": "folder"}]}))print(route_text({"stop_reason": "max_tokens", "content": [ {"type": "text", "text": "Blue"}]}))