OpenAI Function Call API Returns Malformed Arguments - Only Getting Opening Brace

I’m having trouble with OpenAI’s function calling feature. The API keeps returning broken arguments that just contain an opening curly brace instead of proper JSON data.

Here’s my function definition:

const getStockQuote: ChatCompletionFunctions = {
  name: "fetch_stock_quote",
  description: "Retrieve current stock price information",
  parameters: {
    type: "object",
    properties: {
      ticker_symbol: {
        type: "string",
        description: "Stock ticker symbol like AAPL or MSFT",
      },
    },
    required: ["ticker_symbol"],
  },
};

This is how I make the API call:

const apiRequest: CreateChatCompletionRequest = {
  model: "gpt-3.5-turbo-0613",
  temperature: 0.3,
  n: 1,
  messages: conversationHistory,
  function_call: "auto",
  functions: availableFunctions,
};

const result = await openaiClient.createChatCompletion(apiRequest);

But the response I get looks like this:

{"role":"user","content":"get me the price of Apple stock"},{"role":"assistant","content":"","function_call":{"name":"fetch_stock_quote","arguments":"{"}}

The arguments field should contain proper JSON but it only has an opening brace. I’m using the official TypeScript types so the request format should be correct. Has anyone else run into this problem? Any ideas what might be causing this?

sounds like a streaming issue. ive noticed this happening when the response cuts off midway. try adding stream: false to your api request – sometimes the connection can drop before the full json arguments return. also, make sure your openai library version is up to date since older ones had bugs with function calling.