cURL to Vercel AI SDK

Turns a curl call to an OpenAI-compatible chat completions endpoint or an Anthropic messages endpoint into Vercel AI SDK code using generateText or streamText.

Use the tool

Why this tool exists

Provider docs and bug reports usually show a raw curl request. If your app uses the Vercel AI SDK, you then have to work out which parts belong in the model name, the system prompt, the message list and the settings. This tool reads the request body, picks out the model, system text, messages, temperature and max tokens, and writes the matching SDK call. Streaming requests produce streamText, others produce generateText. The API key in the Authorization header is not copied; the output reads it from an environment variable instead, which is where a secret belongs. It is a conversion aid for common chat calls, not a full SDK migration, so review the imports and provider setup. Parsing happens in your browser.

How to use it

  1. Paste a curl command that calls a /chat/completions or Anthropic /messages endpoint.
  2. Run the conversion to get the SDK code.
  3. Copy it into your project and check the provider import and the environment variable name.

Frequently asked questions

Which endpoints does it recognise?

OpenAI-compatible /chat/completions and Anthropic /messages requests with a JSON body. Other endpoints, such as embeddings or image generation, are not converted.

What happens to the API key?

The key is replaced by an environment variable reference, so you never paste a real secret into the code. Set the variable in your own environment.

How does it choose between generateText and streamText?

If the request body contains "stream": true, the converted code uses streamText so you can read tokens as they arrive. Without it, the output uses generateText and returns the whole answer at once.

Are all request fields carried over?

Model, system and chat messages, temperature and max tokens are. Tools, response formats and other provider-specific fields may need to be added by hand.