How to respond that a function call is successful

I have a FastAPI backend sending requests to responses-api and I’m using a chat prompt created here with a tool/function defined: Chat - OpenAI API

I have a first call that look like this:

response = await client.responses.create(

    prompt={

        "id": prompt_id,

        "variables": {

            "current_datetime": datetime.now(timezone.utc).isoformat(),

         },

    },

    input=message

)

That call successfully gets a response back and returns a function_call.
I make the function call, complete it, and want to call response-api again to confirm the result of the function call.

I’ve read and following the instructions here: https://platform.openai.com/docs/api-reference/responses/create and for the life of me I can’t get it to work.

If I understand correctly, my request should look like this:

    await client.responses.create(
    input= [
        {
            "input item list": [
                {
                    "item": {
                        "function tool call output": {
                            "call_id": function_call_id,
                            "output": {"status": "success"},
                            "type": "function_call_output",
                            "status": "completed"
                        },
                        "input message": {
                            "role": "user",
                            "status": "completed"
                        },
                    },
                },
            ],
        },
    ],
    prompt={
        "id": prompt_id,
        "variables": {
            "current_datetime": datetime.now(timezone.utc).isoformat(),
         },
    },
)

I get errors such as: Error code: 400 - {‘error’: {‘message’: “Invalid value: ‘’. Supported values are: ‘assistant’, ‘system’, ‘developer’, and ‘user’.”, ‘type’: ‘invalid_request_error’, ‘param’: ‘input[0]’, ‘code’: ‘invalid_value’}}
which, if I understand correctly, is asking for something that isn’t part of the structure of the documentation.

Anyway, I include a role field it’s asking for, but keep getting errors.

openai.BadRequestError: Error code: 400 - {‘error’: {‘message’: “Unknown parameter: ‘input[0].input item list’.”, ‘type’: ‘invalid_request_error’, ‘param’: ‘input[0].input item list’, ‘code’: ‘unknown_parameter’}}

whereas “input item list” is part of the documentation.

Anyone has any insights, ideas? Thanks in advance.

Besides ‘documents’ instead of API Reference, here’s some reading with Python for you.

At the end of following through, and executing the code snippets as a file or in a notebook environment, you will have responded to an AI’s function call with results and gotten a new response.


The API Reference has objects with names for the schema (dict) that are not names sent to the API.

2 Likes

Thank you! I had not come across that thread in my research.

1 Like