Reduce the amount of data returned from a HTTP request

I am making requests to news item pages. Some times I get the error

Bad request - please check your parameters

This model’s maximum context length is 128000 tokens. However, your messages resulted in 167670 tokens. Please reduce the length of the messages.

How can I reduce the information. I won’t know which divs etc the data are in. Is there a ’ reduce to heading & body text’. ?

Information on your n8n setup

  • n8n version: 1.59
  • **Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default:):
  • Running n8n via (render):
  • Operating system: Win 10

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hey @Steve_Warburton , it depends on the API you access. Does it provide any solution to request a partial data returned? See if you can locate their API docs and if their offer any parameters that could be sent together with your HTTP request to instruct the API to replies with the controlled size of the data.

I am just using a http request node to get the html from url.

Hey @Steve_Warburton , perhaps I misunderstood you first.

Let me correct myself and see if I’m getting it right this time. You seem to be getting some information from the website (plain HTML) and then try to feed it into some other service (AI ?). Thus, you want to shorten the data sent to that other service?

Are you looking to strip off all the HTML tags? Could you share a link to the webpage you are trying to relay to the other service?

I used the following in a code node

it seems to be enough to get enough to create a summary of the news item.

1 Like

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