Tutorial

Migrating from Anthropic & OpenAI

Switch from direct Anthropic or OpenAI API integrations in under 5 minutes. Enjoy up to 70% cost reduction on Claude models with zero prompt changes and unified failovers.

Why Migrate?

Calling Anthropic directly requires managing a separate SDK (@anthropic-ai/sdk), handling different message payload formats, and paying full retail token pricing (\$3.00 / \$15.00 per million tokens for Claude 3.5 Sonnet).

With InfinityRouter, you use the standard OpenAI interface, gain automatic multi-upstream redundancy, and access wholesale rates that are up to 70% cheaper.

1. Model Identifier Mapping

Replace verbose dated model names with our clean canonical identifiers:

Model identifier mapping
Anthropic / OpenAI IDInfinityRouter Canonical IDPricing Advantage
claude-3-5-sonnet-20241022claude-sonnet-570% Cheaper
claude-3-5-haiku-20241022claude-haiku-470% Cheaper
gpt-4o-2024-08-06gpt-4oWholesale Rates
deepseek-reasonerdeepseek-r1Lowest Published

2. Code Comparison: Before vs After

Before: Direct Anthropic SDK (Python)

pythonBefore (Anthropic SDK)
  # Requires anthropic package and unique client methods
  import anthropic

  client = anthropic.Anthropic(api_key="sk-ant-...")

  message = client.messages.create(
      model="claude-3-5-sonnet-20241022",
      max_tokens=1000,
      system="You are a helpful analyst.",
      messages=[{"role": "user", "content": "Analyze our quarterly churn rate."}]
  )
  print(message.content[0].text)

After: InfinityRouter (OpenAI SDK with 70% Savings)

pythonAfter (InfinityRouter)
  # Uses standard openai package and OpenAI-compatible messages format
  from openai import OpenAI

  client = OpenAI(
      base_url="https://infinityrouter.qd.je/v1",
      api_key="inf_live_...",
  )

  response = client.chat.completions.create(
      model="claude-sonnet-5",
      messages=[
          {"role": "system", "content": "You are a helpful analyst."},
          {"role": "user", "content": "Analyze our quarterly churn rate."}
      ],
  )
  print(response.choices[0].message.content)

3. Automatic System Prompt Translation

In OpenAI specifications, system instructions are passed as a message object with role: "system". InfinityRouter automatically translates this into the native format required by downstream providers like Anthropic without requiring changes on your client.

Need custom rate limits or private model provisioning? Open a support ticket from your Dashboard Support portal to configure dedicated routing policies.