Function Calling parameter types

What are the types that can be passed as parameters? I can only seem to set the type as a string.
can you set more complex types? i.e Array, two dimensional Array, objects, etc

I’m sure I’m doing something wrong. If I set the type to array I get 400 Bad request

properties: {
                       key: {
                           type: "string",
                           description: "example description"

The other day I do remember seeing the JSON schema for OpenAI functions. I think I even bookmarked the web page because it was three degrees of separation from the blog page.

Sadly I cannot find the page nor the link.

However ChatGPT does seem to possess some knowledge of the JSON schema so prompted ChatGPT.

ChatGPT May 24 Version

What is the JSON schema for OpenAI function properties for a two dimensional array.


As of my knowledge cutoff in September 2021, OpenAI does not provide a specific JSON schema for function properties that includes a two-dimensional array. However, you can define the structure of a two-dimensional array within the function properties using a nested array structure. Here’s an example of how you might structure the properties for an OpenAI function with a two-dimensional array using JSON:


  "name": "MyFunction",
  "description": "This is a sample function",
  "parameters": [
      "name": "array",
      "type": "array",
      "description": "Two-dimensional array",
      "items": {
        "type": "array",
        "items": {
          "type": "number"
  "output": {
    "type": "array",
    "items": {
      "type": "array",
      "items": {
        "type": "number"

In this example, the function has a parameter named “array” which is an array of arrays. The inner arrays represent rows in the two-dimensional array, and each element within the inner arrays represents a value in the two-dimensional array (in this case, numbers). The output of the function is also a two-dimensional array with the same structure.

Please note that the actual schema for OpenAI function properties may differ depending on the specific implementation and requirements of the OpenAI API. It’s always a good idea to refer to the official OpenAI documentation or resources for the most up-to-date and accurate information on function properties.

I have not tried this.


IIRC this is what I found the other day, may or may not be correct.

This OpenAI API reference page

Section: Create chat completion


parameters object Optional

The parameters the functions accepts, described as a JSON Schema object. See the guide for examples, and the JSON Schema reference for documentation about the format.

Here is the noted JSON Schema



nice ok I will try this and see what happens :ok_hand:

You can have a look into this post and the reference @EricGT provided.

1 Like

I found using pydantic made things easier for me and worked well with str, int, lists and dictionaries.

Here is an example where I extract data from a set of user interviews.

from pydantic import BaseModel, Field
from typing import Optional, List

# define function structure in pydantic

class Topic(BaseModel):
    name: str = Field(..., description="Classification category")
    count: int = Field(..., description="Count for the category")

class ExtractInsightsParams(BaseModel):
    interviewee_names: List[str] = Field(..., description="The names of the interviewees, e.g. Christoph, person y")
    interviewee_count: int = Field(..., description="Number of people interviewed")
    interview_topics: List[Topic] = Field(..., description="List of top 10 classification categories with their counts")

Then I use it in my function:

def get_completion_from_messages(messages, 
    response = openai.ChatCompletion.create(
          "name": "extract_insights",
          "description": "Extract insights from interviews",
          "parameters": ExtractInsightsParams.schema()
    function_call = response.choices[0].message["function_call"]
    arguments = json.loads(function_call["arguments"])
    return arguments

Really clever way. Sometimes we cannot see the forest because of all the trees.

1 Like