AzureChatOpenAI BadRequestError: 400 Missing required parameter #75

Closed
opened 2026-02-15 17:15:26 -05:00 by yindo · 1 comment
Owner

Originally created by @jamesdam on GitHub (Aug 27, 2024).

I am trying out the example from README, except that I use AzureChatOpenAI instead of ChatAnthropic

Here is how I init the model

const model = new AzureChatOpenAI({
  model: "gpt-4o-mini",
  temperature: 0,
  maxRetries: 2,
  azureOpenAIApiKey: process.env.AZURE_OPENAI_API_KEY, // In Node.js defaults to process.env.AZURE_OPENAI_API_KEY
  azureOpenAIApiInstanceName: process.env.AZURE_OPENAI_API_INSTANCE_NAME, // In Node.js defaults to process.env.AZURE_OPENAI_API_INSTANCE_NAME
  azureOpenAIApiDeploymentName: process.env.AZURE_OPENAI_API_DEPLOYMENT_NAME, // In Node.js defaults to process.env.AZURE_OPENAI_API_DEPLOYMENT_NAME
  azureOpenAIApiVersion: process.env.AZURE_OPENAI_API_VERSION, // In Node.js defaults to process.env.AZURE_OPENAI_API_VERSION
});

The first app.invoke call works fine, but the second one throws error.

BadRequestError: 400 Missing required parameter: 'messages[1].function_call.name'.
    at APIError.generate ([xxx]/notebooks/node_modules/openai/error.js:45:20)
    at AzureOpenAI.makeStatusError ([xxx]/notebooks/node_modules/openai/core.js:275:33)
    at AzureOpenAI.makeRequest ([xxx]/notebooks/node_modules/openai/core.js:318:30)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async [xxx]/notebooks/node_modules/@langchain/openai/dist/chat_models.cjs:1351:29
    at async RetryOperation._fn ([xxx]/notebooks/node_modules/p-retry/index.js:50:12) {
  status: 400,
  headers: {
    'apim-request-id': '0b0db2bf-e4f1-4b9a-8544-bf120a0e9f5d',
    'azureml-model-session': 'd005-20240823162121',
    'content-length': '225',
    'content-type': 'application/json',
    date: 'Wed, 28 Aug 2024 02:09:37 GMT',
    'ms-azureml-model-error-reason': 'model_error',
    'ms-azureml-model-error-statuscode': '400',
    'strict-transport-security': 'max-age=31536000; includeSubDomains; preload',
    'x-content-type-options': 'nosniff',
    'x-envoy-upstream-service-time': '15',
    'x-ms-client-request-id': '0b0db2bf-e4f1-4b9a-8544-bf120a0e9f5d',
    'x-ms-rai-invoked': 'true',
    'x-ms-region': 'East US',
    'x-ratelimit-remaining-requests': '9987',
    'x-ratelimit-remaining-tokens': '997041',
    'x-request-id': '538835ed-eb05-42fe-a0fb-2a9e4bfc5a64'
  },
  request_id: '538835ed-eb05-42fe-a0fb-2a9e4bfc5a64',
  error: {
    message: "Missing required parameter: 'messages[1].function_call.name'.",
    type: 'invalid_request_error',
    param: 'messages[1].function_call.name',
    code: 'missing_required_parameter'
  },
  code: 'missing_required_parameter',
  param: 'messages[1].function_call.name',
  type: 'invalid_request_error',
  attemptNumber: 1,
  retriesLeft: 2,
  pregelTaskId: '44d3da58-e21d-550c-b539-de1e4ee50fcf'
}

My package.json dependencies:

"@langchain/langgraph": "^0.1.4",
"@langchain/openai": "^0.2.8",
"langchain": "^0.2.17",
Originally created by @jamesdam on GitHub (Aug 27, 2024). I am trying out the example from README, except that I use AzureChatOpenAI instead of ChatAnthropic Here is how I init the model ``` const model = new AzureChatOpenAI({ model: "gpt-4o-mini", temperature: 0, maxRetries: 2, azureOpenAIApiKey: process.env.AZURE_OPENAI_API_KEY, // In Node.js defaults to process.env.AZURE_OPENAI_API_KEY azureOpenAIApiInstanceName: process.env.AZURE_OPENAI_API_INSTANCE_NAME, // In Node.js defaults to process.env.AZURE_OPENAI_API_INSTANCE_NAME azureOpenAIApiDeploymentName: process.env.AZURE_OPENAI_API_DEPLOYMENT_NAME, // In Node.js defaults to process.env.AZURE_OPENAI_API_DEPLOYMENT_NAME azureOpenAIApiVersion: process.env.AZURE_OPENAI_API_VERSION, // In Node.js defaults to process.env.AZURE_OPENAI_API_VERSION }); ``` The first app.invoke call works fine, but the second one throws error. ``` BadRequestError: 400 Missing required parameter: 'messages[1].function_call.name'. at APIError.generate ([xxx]/notebooks/node_modules/openai/error.js:45:20) at AzureOpenAI.makeStatusError ([xxx]/notebooks/node_modules/openai/core.js:275:33) at AzureOpenAI.makeRequest ([xxx]/notebooks/node_modules/openai/core.js:318:30) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async [xxx]/notebooks/node_modules/@langchain/openai/dist/chat_models.cjs:1351:29 at async RetryOperation._fn ([xxx]/notebooks/node_modules/p-retry/index.js:50:12) { status: 400, headers: { 'apim-request-id': '0b0db2bf-e4f1-4b9a-8544-bf120a0e9f5d', 'azureml-model-session': 'd005-20240823162121', 'content-length': '225', 'content-type': 'application/json', date: 'Wed, 28 Aug 2024 02:09:37 GMT', 'ms-azureml-model-error-reason': 'model_error', 'ms-azureml-model-error-statuscode': '400', 'strict-transport-security': 'max-age=31536000; includeSubDomains; preload', 'x-content-type-options': 'nosniff', 'x-envoy-upstream-service-time': '15', 'x-ms-client-request-id': '0b0db2bf-e4f1-4b9a-8544-bf120a0e9f5d', 'x-ms-rai-invoked': 'true', 'x-ms-region': 'East US', 'x-ratelimit-remaining-requests': '9987', 'x-ratelimit-remaining-tokens': '997041', 'x-request-id': '538835ed-eb05-42fe-a0fb-2a9e4bfc5a64' }, request_id: '538835ed-eb05-42fe-a0fb-2a9e4bfc5a64', error: { message: "Missing required parameter: 'messages[1].function_call.name'.", type: 'invalid_request_error', param: 'messages[1].function_call.name', code: 'missing_required_parameter' }, code: 'missing_required_parameter', param: 'messages[1].function_call.name', type: 'invalid_request_error', attemptNumber: 1, retriesLeft: 2, pregelTaskId: '44d3da58-e21d-550c-b539-de1e4ee50fcf' } ``` My package.json dependencies: ``` "@langchain/langgraph": "^0.1.4", "@langchain/openai": "^0.2.8", "langchain": "^0.2.17", ```
yindo added the bug label 2026-02-15 17:15:26 -05:00
yindo closed this issue 2026-02-15 17:15:26 -05:00
Author
Owner

@dqbd commented on GitHub (Sep 11, 2025):

Hello! Cannot reproduce this issue on my end. If the issue still occurs, please create a new issue with a MRE if possible, thank you!

@dqbd commented on GitHub (Sep 11, 2025): Hello! Cannot reproduce this issue on my end. If the issue still occurs, please create a new issue with a MRE if possible, thank you!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraphjs#75