cURL to OpenAI SDK

Paste an OpenAI cURL example from the docs, get equivalent code using the official OpenAI Python or Node SDK. Handles chat completions, embeddings, audio transcription. Extracts the model, messages, and parameters automatically.

How to use the cURL to OpenAI SDK

Paste any OpenAI cURL example. The tool detects the endpoint (chat completions, embeddings, audio) and generates the matching SDK call. Streaming option wraps the call in the iterator pattern. The API key is read from OPENAI_API_KEY environment variable in the generated code (don't hard-code keys).

From OpenAI cURL to SDK code

OpenAI’s documentation shows requests as cURL, but production code uses the SDK — and the mapping is not always obvious, because the same cURL shape can hit chat completions, embeddings, or audio endpoints, each with a different SDK method. Transcribing by hand means spotting the endpoint first, then rebuilding the parameters in the SDK’s shape.

This detects the endpoint from an OpenAI cURL command and generates the matching call for the official Python or Node SDK, with an optional streaming wrapper and the key read from OPENAI_API_KEY. For Anthropic’s API use the cURL to Anthropic SDK converter, and when you want a generic language port rather than the SDK, the cURL to Python converter outputs requests code.

Common use cases

  • Docs to code — convert an OpenAI cURL example into SDK code.
  • Endpoint detection — get the right call for chat, embeddings, or audio.
  • Cross-language — emit Python or Node from the same command.
  • Streaming — wrap a chat call in the streaming iterator automatically.
  • Onboarding — show how the REST shape maps onto SDK methods.

Frequently asked questions

Which endpoints are supported?

Chat completions, embeddings, and audio transcription, detected from the command.

Python or Node?

Both — the official openai SDK for each.

Are keys hard-coded?

No — generated code reads OPENAI_API_KEY from the environment.

What about Anthropic Claude?

Use the cURL to Anthropic SDK converter for the 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: