openai.BadRequestError: Error code: 400 - {'error': {'message': "Invalid schema for function 'createproductSF': 'dict' is not valid under any of the given schemas", 'type': 'invalid_request_error', 'param': 'tools[0]', 'code': None}}

I am facing the above mentioned error when I am using the assistant to call a function having parameter of type dict. Following is my code:

import ast
import json
import openai
import time
import requests

def createproductSF(input: dict) -> str:
        url = ""
        bearerToken = 'auth-token';
        headers = {
        new_input=input.replace('data = ','')
        res =,headers=headers,json=data)
        return str(res)

tools_list = [{
    "type": "function",
    "function": {

        "name": "createproductSF",
        "description": "This will create a product in SubscriptionFlow by getting a dict object if it is present that is given as input to this function and will send a request to subscriptionflow to create a product with the data",
        "parameters": {
            "type": "object",
            "properties": {
                "input": {
                    "type": "dict",
                    "description": "This is the JSON product data which will be used by the function to send a post request for product creation purpose"
            "required": ["input"]

# Initialize the client
client = openai.OpenAI(api_key='your api-key')

# file_id=client.files.create(file=open('demo.csv'), purpose='assistants').id

# Step 1: Create an Assistant
assistant = client.beta.assistants.create(
    name="SubscriptionFlow Assistant",
    instructions="You are a professional SubscriptionFlow assistant. Write and run user's queries and answer them with relevance to SubscriptionFlow.",

# Step 2: Create a Thread
thread = client.beta.threads.create()

# Step 3: Add a Message to a Thread
message = client.beta.threads.messages.create(,
    content='data={"name": "Test Product","description": "This is a test product"}'

# Step 4: Run the Assistant
run = client.beta.threads.runs.submit_tool_outputs(,,
  instructions="Please address the user as Shaff Khan. The user has a premium account.",


while True:
    # Wait for 5 seconds

    # Retrieve the run status
    run_status = client.beta.threads.runs.retrieve(,

    # If run is completed, get messages
    if run_status.status == 'completed':
        messages = client.beta.threads.messages.list(
        # Loop through messages and print content based on role
        for msg in
            role = msg.role
            content = msg.content[0].text.value
            print(f"{role.capitalize()}: {content}")

That’s not an API key you just made public, is it?

Are you talking about OpenAI API key ?

Oh, looks like you removed it, for a second there I swear you had the bearer token on there.

Thanks for pointing that out. I’ll be careful next time.