FG
🤖 AI & LLMsOpenAI

Is 'functions' parameter not supported?

Freshabout 21 hours ago
Mar 14, 20260 views
Confidence Score56%
56%

Problem

Describe the bug I'm trying to use the functions parameter to help force JSON response. Is this not supported? To Reproduce Call createChatCompletion with 'functions' array. Code snippets [code block] Results in the error: [code block] ``` OS macOS Node version 18.7.0 Library version 3.3.0

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Update API Call to Support Functions Parameter

Medium Risk

The 'functions' parameter may not be supported in the current version of the OpenAI API you are using (3.3.0). This could be due to either the API version not implementing this feature or incorrect usage in your code. Ensure that you are using a version of the API that supports the 'functions' parameter.

Awaiting Verification

Be the first to verify this fix

  1. 1

    Check API Documentation

    Review the OpenAI API documentation to confirm that the 'functions' parameter is supported in the version you are using. If it is not mentioned, you may need to upgrade to a newer version.

  2. 2

    Upgrade OpenAI Library

    If the 'functions' parameter is supported in a later version, upgrade your OpenAI library to the latest version using npm. This can be done by running the following command in your terminal.

    bash
    npm install openai@latest
  3. 3

    Modify API Call

    Ensure that your API call correctly includes the 'functions' parameter as per the latest API specifications. Here is an example of how to structure the call.

    typescript
    const response = await openai.createChatCompletion({ model: 'gpt-3.5-turbo', functions: [{ name: 'functionName', description: 'Function description' }], ...otherParams });
  4. 4

    Test the API Call

    Run your application again to test if the API call with the 'functions' parameter works as expected. Monitor for any errors or unexpected behavior.

Validation

Confirm that the API call executes successfully without errors and that the response includes the expected JSON format. You can log the response to verify its structure.

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

openaigptllmapibug