Retrieving Full Response from N8N OpenAI Node

Hello,

I am in the process of setting up the N8N OpenAI Node, and everything is functioning well so far. However, I have a query regarding the chat.completion API. I am curious to know if it is possible to receive the full response, including the “usage” section, as shown in the example below:

{
    "id": "chatcmpl-abc123",
    "object": "chat.completion",
    "created": 1677858242,
    "model": "gpt-3.5-turbo-1106",
    "usage": {
        "prompt_tokens": 13,
        "completion_tokens": 7,
        "total_tokens": 20
    },
    "choices": [
        {
            "message": {
                "role": "assistant",
                "content": "\n\nThis is a test!"
            },
            "finish_reason": "stop",
            "index": 0
        }
    ]
}

Currently, I am only receiving the choices array in the response. Is this the intended design, or is there something I might be overlooking?

Thank you for your assistance.

You could use the requests node and call the openai api like that. This offers a bit more flexibility.

1 Like

Thanks, will try that!

1 Like

Hey @dennisschneider,

Welcome to the community :tada:

I have just taken a quick look and if you turn off the Simplify option this will output the usage as well. Is this what you are after?

1 Like

awesome, exactly what i was looking for … overlooked that somehow … thank you :raised_hands:

1 Like

Hey @dennisschneider,

No problem at all, It happens :slight_smile:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.