Guides

Python & TypeScript

Use the official Anthropic SDKs with Hephaestus.

Install the official SDK and set two values: the base URL and your key. Everything else is identical to calling Anthropic directly.

Install

terminal
pip install anthropic

Configure with environment variables

Both SDKs read these automatically, so your code needs no changes:

.env
ANTHROPIC_BASE_URL=https://api.gethephaestus.com
ANTHROPIC_API_KEY=hph_live_YOUR_KEY

Streaming

Stream anything that might take a while. It avoids timeouts and feels faster.

stream.py
from anthropic import Anthropic

client = Anthropic()  # reads ANTHROPIC_BASE_URL / ANTHROPIC_API_KEY

with client.messages.stream(
    model="claude-sonnet-5-5",
    max_tokens=4096,
    messages=[{"role": "user", "content": "Write a haiku about load-shedding"}],
) as stream:
    for text in stream.text_stream:
        print(text, end="", flush=True)

final = stream.get_final_message()
print("\ntokens:", final.usage.input_tokens, "in,", final.usage.output_tokens, "out")

Tool use

Tools, parallel tool calls, vision and extended thinking all work the way Anthropic documents them. Nothing is stripped or rewritten on the way through.

Prompt caching

Add cache_control to long, reusable prompt prefixes to pay a fraction of the input price on every repeat. See How billing works for the exact rates.

cache.py
message = client.messages.create(
    model="claude-sonnet-5-5",
    max_tokens=1024,
    system=[{"type": "text", "text": LONG_REFERENCE_DOC, "cache_control": {"type": "ephemeral"}}],
    messages=[{"role": "user", "content": "Summarise section 3"}],
)
print(message.usage)  # cache_creation_input_tokens, cache_read_input_tokens