cURL to Anthropic SDK

Paste an Anthropic Claude cURL example, get equivalent code using the official anthropic Python SDK or @anthropic-ai/sdk for Node. Handles Messages API, system prompts, tool use, streaming, prompt caching.

How to use the cURL to Anthropic SDK

Paste an Anthropic Claude cURL example. The tool extracts model, system prompt, messages, max_tokens, and any tool definitions. The generated SDK code reads ANTHROPIC_API_KEY from the environment. Stream option uses the SDK's MessageStream iterator.

From Anthropic cURL to SDK code

Anthropic’s API docs give examples as cURL commands, but shipping code means rewriting them as SDK calls — moving the model, system prompt, message list, max_tokens, and any tool definitions out of the JSON body and into the SDK’s method signatures. Doing that by hand for every example is repetitive, and small omissions like a missing max_tokens or a mis-nested tool schema only surface at runtime.

This reads an Anthropic Messages API cURL command and emits equivalent code for the official anthropic Python SDK or @anthropic-ai/sdk for Node, including the streaming variant, with the key read from ANTHROPIC_API_KEY rather than hard-coded. For OpenAI’s API the cURL to OpenAI SDK converter does the same, and for a plain language port without an LLM SDK, the cURL to Python converter produces requests code.

Common use cases

  • Docs to code — turn an Anthropic docs cURL snippet into a real SDK call.
  • Switch languages — get the same request as Python or Node SDK code.
  • Add streaming — produce the MessageStream version without learning the API.
  • Tool use — carry tool definitions across into the SDK call.
  • Learning the SDK — see how a raw request maps to SDK methods.

Frequently asked questions

Which SDKs does it target?

The official anthropic Python SDK and @anthropic-ai/sdk for Node.

Does it handle tool use and streaming?

Yes — tool definitions are carried over, and the streaming option uses the SDK's stream iterator.

Is my API key exposed?

No — the generated code reads ANTHROPIC_API_KEY from the environment; nothing is hard-coded.

What about OpenAI requests?

Use the cURL to OpenAI SDK converter; this one targets Anthropic’s Messages API.
Embed this tool on your site

Free to embed, no attribution required (but appreciated). Paste this where you want the tool to appear: