Integrate with LLMs
Anthropic Claude
Setup
pip install anthropicimport os
from anthropic import Anthropic
client = Anthropic(api_key=os.environ.get("ANTHROPIC_API_KEY"))Basic Message
from hypergraph import node
@node(output_name="response")
def generate(prompt: str, system: str = "") -> str:
"""Generate a response using Claude Sonnet 4.5."""
message = client.messages.create(
model="claude-sonnet-4-5-20250929",
max_tokens=1024,
system=system,
messages=[{"role": "user", "content": prompt}],
)
return message.content[0].textStreaming
Multi-Turn Conversation
Model Options
Model
Use Case
OpenAI GPT
Setup
Basic Response (Responses API)
Streaming
Multi-Turn with State
With Tools
Model Options
Model
Use Case
RAG Pattern
Structured Outputs
With Anthropic
With OpenAI
Error Handling
Dependency Injection with .bind()
Testing LLM Nodes
What's Next?
Last updated