BadRequestError 400 Unsupported data type when creating Azure OpenAI assistant

I keep getting a BadRequestError: 400 Unsupported data type when trying to create an assistant with Azure OpenAI. Regular chat completions work perfectly fine with the same API credentials, but assistant creation fails every time.

I’ve been following the official Azure OpenAI documentation but can’t figure out what’s wrong. Here’s my implementation:

require('dotenv').config();
const { AzureOpenAI } = require('openai');

const azureEndpoint = process.env.AZURE_ENDPOINT;
const key = process.env.AZURE_API_KEY;
const version = process.env.API_VERSION;
const modelDeployment = process.env.MODEL_DEPLOYMENT;

const openaiClient = new AzureOpenAI({
  endpoint: azureEndpoint,
  apiKey: key,
  apiVersion: version,
  deployment: modelDeployment
});

async function createMathAssistant() {
  try {
    const mathHelper = await openaiClient.beta.assistants.create({
      name: "Math Helper",
      instructions: "You are a helpful math tutor. Use code to solve mathematical problems when needed.",
      tools: [{ type: "code_interpreter" }],
      model: "gpt-4o"
    });
    
    console.log("Math assistant created:", mathHelper);
  } catch (err) {
    console.error("Failed to create assistant:", err);
  }
}

createMatAssistant();

The error message isn’t very helpful. Has anyone encountered this issue before? What could be causing the unsupported data type error?

You’ve got a typo - you’re calling createMatAssistant() but your function is createMathAssistant(). That’ll break before you even reach the API.

I’ve hit this 400 error when the API version doesn’t support what you’re using. Code interpreter and assistants are newer features, so try 2024-02-15-preview or later.

Double-check your MODEL_DEPLOYMENT env variable exists and matches your Azure deployment name exactly. Case matters.

I’ve been through this pain building our internal AI tools - wasted hours on Azure quirks. Now I prototype in visual builders first to validate logic before coding.

Still broken? Add logging to see what values actually hit the API call. Env vars don’t always load right.

Besides that typo everyone mentioned, I hit this same error when my Azure region didn’t fully support the assistants API. That 400 unsupported data type error is misleading - it’s really about feature availability. Switched from East US to East US 2 and the same code worked fine. Microsoft rolls features out gradually, and assistants API isn’t available everywhere yet. Also got burned trying to use tools that weren’t enabled on my deployment. Your model might support code interpreter, but your specific Azure deployment might not have it turned on. Check your deployment settings in the Azure portal. If you’re still getting errors after fixing that function name typo, try making a basic assistant first - just name, instructions, and model. No tools or fancy stuff. That’ll show you if it’s a tools problem or something wrong with your setup.

check your Azure OpenAI service tier - basic tier doesn’t support assistants API at all. I got burned on this, kept getting 400 errors until I upgraded to standard. also make sure your deployment has the latest model version, older ones throw weird data type errors even with correct syntax.

This happens when there’s a mismatch between your Azure deployment and what you’re sending.

I’ve hit this exact issue - the model parameter needs to be your deployment name, not “gpt-4o”.

Change this:

model: "gpt-4o"

To this:

model: modelDeployment

Also verify your Azure deployment actually supports assistants API and code interpreter tools. Not all deployments have these enabled.

Honestly, Azure OpenAI quirks get old fast. I moved to automating my AI workflows through Latenode since it handles these API inconsistencies. You just connect services and build workflows without dealing with deployment names or version mismatches.

Latenode has built-in OpenAI nodes that work reliably across providers. Way cleaner than debugging config issues.

Had this exact problem last month and wasted way too much time on it. For me, it was the wrong API version plus an outdated deployment model. Azure’s error messages suck - “unsupported data type” actually means your deployment config doesn’t match what you’re asking for. Fix that function name typo others mentioned first. Then check if your deployment actually has GPT-4 or if it’s still running GPT-3.5. I was sending gpt-4o requests to a 3.5-turbo deployment and got the same cryptic error. Also make sure your API version supports assistants - anything before 2024-02-01 won’t work. I’m using 2024-05-01-preview now with no issues. One thing nobody mentioned - some Azure subscriptions restrict access to certain features. Enterprise accounts sometimes block the assistants API completely. Check with your admin if you’re on a corporate subscription. I wasted two days before finding out our IT team had disabled it.