Anthropic SDK
Use the official Anthropic SDKs for Python and TypeScript with InterOdin.
The official Anthropic SDKs work unchanged against /v1/messages.
Base URL: use the origin, https://api.interodin.com, without /v1. The SDK adds /v1/messages itself.
Install
pip install anthropicConfigure
import os
import anthropic
client = anthropic.Anthropic(
base_url="https://api.interodin.com",
api_key=os.environ["INTERODIN_API_KEY"],
)
message = client.messages.create(
model="odin-v1",
max_tokens=1024,
messages=[{"role": "user", "content": "Say hello in Romanian."}],
)
print("".join(block.text for block in message.content if block.type == "text"))Or configure it through the environment variables the SDKs read:
export ANTHROPIC_BASE_URL="https://api.interodin.com"
export ANTHROPIC_API_KEY="io-sk-your-key"api_key / apiKey sends the key as x-api-key. If you prefer Authorization: Bearer, pass it as auth_token (Python) or authToken (TypeScript), or set ANTHROPIC_AUTH_TOKEN. Both are accepted.
Streaming and token counting
import os
import anthropic
client = anthropic.Anthropic(base_url="https://api.interodin.com", api_key=os.environ["INTERODIN_API_KEY"])
count = client.messages.count_tokens(
model="odin-v1",
messages=[{"role": "user", "content": "Write a haiku about Odin."}],
)
print("input tokens:", count.input_tokens)
with client.messages.stream(
model="odin-v1",
max_tokens=512,
messages=[{"role": "user", "content": "Write a haiku about Odin."}],
) as stream:
for text in stream.text_stream:
print(text, end="", flush=True)Token counting is not billed (it still counts toward rate limits).
Good to know
- Model id. Use
odin-v1. Model names the SDK suggests for other providers return404 model_not_found. - Prompt caching is automatic.
cache_controlblocks are accepted and ignored. See Prompt caching. - Images. Odin v1 is text-only, so an
imageblock in the newest message returns400 image_input_not_supported. Images in tool results or earlier turns are replaced by a text note. - Documents. A
documentblock in the newest message returns400 unsupported_content. - Tools. Custom tools and the web search tool (
web_search_20250305, up to 5 searches per request, billed per search) work. Other typed tools (code execution, bash, text editor, computer use) andmcp_serversare removed from the request without an error. See Web search. - Models.
client.models.list()returns the Anthropic-format list, because the SDK sendsanthropic-version. - Errors arrive in Anthropic's format, so the SDK raises its usual exceptions. A
402 billing_errormeans your balance is used up. To tell codes that share an error type apart, read thex-interodin-error-coderesponse header.
More: Messages guide.