Skip to main content

Feb 18, 2026

Native Anthropic SDK support for the AI Gateway

289 words

Topics:
ngrok.ai is now an all-new experience at app.ngrok.ai, with a dedicated dashboard, API, and gateway URL, and new accounts get $1 in credit to make their first requests. Read The new ngrok.ai for the full story.

ngrok’s AI gateway now supports Anthropic’s SDK natively.

When we launched early access, the gateway only spoke OpenAI’s API format. That works if you’re on the OpenAI SDK, but early users building with Anthropic’s SDK told us switching wasn’t an option, especially when they rely on Claude-specific features like prompt caching, extended thinking, or beta headers.

So we fixed it.

How it works

When using the Anthropic SDK, change your base URL to your gateway endpoint:

1import anthropic2 3client = anthropic.Anthropic(4    base_url="https://your-gateway.ngrok.app",5    api_key="your-api-key"6)7 8message = client.messages.create(9    model="claude-opus-4-5",10    max_tokens=1024,11    messages=[{"role": "user", "content": "Hello!"}]12)

The gateway automatically detects Anthropic SDK requests and forwards them unchanged. When Anthropic ships new features, you can use them immediately. The same approach works in TypeScript; see our Anthropic SDK docs for examples.

Everything else you’d expect from the gateway still works: automatic failover across API keys, model selection with ngrok/auto, streaming, tool use, and Traffic Policy.

Limitations

Anthropic SDK requests can only route to providers that support the Claude Messages API. In our catalog, that’s currently just Anthropic. If you need cross-provider failover, you can either use both SDKs in your codebase or stick with the OpenAI SDK alone.

Getting started

If you’re already on the AI Gateway, change the base URL and you’re set. New to ngrok.ai? Sign in at app.ngrok.ai (new accounts get $1 in credit) and check out our quickstart guide.

Questions or feedback? Reach out.