Anthropic SDK Compatibility — ML Junction docs

Point the official Anthropic SDK at /anthropic. ML Junction implements POST /anthropic/v1/messages with Anthropic-shaped success, streaming, tool, usage, request-ID, and error behavior.

import os
from anthropic import Anthropic
client = Anthropic(
    api_key=os.environ["MLJUNCTION_API_KEY"],
    base_url="https://api.mljunction.com/anthropic",
)
message = client.messages.create(
    model="claude-opus-4-6",
    max_tokens=1200,
    system="Be precise.",
    messages=[{"role": "user", "content": "Explain route receipts."}],
    extra_body={
        "mlj": {
            "routing": {
                "provider": "anthropic",
                "require_zdr": True,
                "max_platform_charge_usd": 0.05,
            },
            "session_name": "docs-example",
            "task_name": "explain-receipts",
        }
    },
)
print(message.content[0].text)
print(message.mlj["receipt"])
import Anthropic from '@anthropic-ai/sdk';
const client = new Anthropic({
  apiKey: process.env.MLJUNCTION_API_KEY,
  baseURL: 'https://api.mljunction.com/anthropic',
});
const stream = await client.messages.stream({
  model: 'claude-opus-4-6',
  max_tokens: 1200,
  messages: [{ role: 'user', content: 'Stream a deployment checklist.' }],
  mlj: { routing: { strategy: 'quality', provider: 'anthropic' } },
});

for await (const event of stream) console.log(event.type);

Messages feature · Status · Notes
Text and system prompts · Supported · String and text-block system prompts
Streaming · Supported · Official Anthropic event ordering
Tool use / tool results · Supported · Mapped to the native function-tool pipeline
Images · Supported · URL and base64 sources
output_config.format · Supported · Strict schema output; structured streams are atomic
thinking / redacted_thinking · Preserved · Opaque blocks remain provider-bound
Message Batches, Files, token counting · Not emulated · Use native ML Junction batch/files surfaces where available

Signed or redacted Anthropic thinking is detected before execution. Non-Anthropic routes and routes without reasoning-continuity support are excluded; incompatible explicit routing returns HTTP 400. Token counts alone are portable telemetry and do not pin a provider.

Canonical URL: https://mljunction.com/docs/anthropic-compatibility