OpenAI Chat Messages <-> Vercel AI SDK CoreMessage Converter

Paste a messages array and convert it between the OpenAI Chat Completions format and Vercel AI SDK CoreMessage, including image parts, tool calls and tool results, for AI SDK 4 or 5.

Use the tool

Why this tool exists

The two formats look alike but differ in the details. OpenAI nests images under image_url and sends tool arguments as a JSON string. The AI SDK uses image parts, tool-call parts with parsed objects, and separate tool-result parts. When you move a chat history, a test fixture or a logged conversation from one world to the other, those differences cause quiet failures.

AI SDK 5 also renamed the fields from args and result to input and output. This converter handles both directions and both versions, so you can fix a fixture in seconds. It runs in your browser, which is useful when the conversation you are converting contains real user messages.

How to use it

  1. Paste your messages array as JSON into the input box.
  2. Choose the direction, either OpenAI to AI SDK or AI SDK to OpenAI.
  3. Select AI SDK version 5 (input and output) or version 4 (args and result).
  4. Copy the converted JSON into your code or test fixture.

Frequently asked questions

Which roles are supported?

System, developer, user, assistant and tool messages are converted. Any other role stops the conversion with an error naming it, so you can fix the input rather than lose a message silently.

What happens to tool call arguments?

Going to the AI SDK, the JSON string is parsed into an object. If it is not valid JSON, the raw string is kept. Going back to OpenAI, the object is stringified again.

Is the output guaranteed to be accepted by the SDK?

It follows the documented shapes, but SDK versions change. Check the result against the version you have installed, especially for audio, files and other less common content parts.