Content negotiation allows clients to request different representations of the same resource using the HTTP-standard Accept header, rather than requiring different URLs.
For example, the Vercel documentation uses this technique to respond with markdown when an agent requests docs:
This guide assumes that your content is authored using markdown in a Next.js app, but can be adapted to your content authoring strategy and framework by converting your content to markdown on-the-fly.
Copy link to headingCreate a Route Handler for markdown responses
First, create a Route Handler that returns markdown responses when it is requested:
Copy link to headingCreating conditional responses
Add a function to your next.config.ts that handles the Accept header and use it to rewrite to the Route Handler you created previously:
Copy link to headingAdd a sitemap.md
Leave a discovery point to the rest of your documentation in these responses, so the LLM knows where to continue searching for helpful content if it doesn’t find what it needs on the first try.
For example, see the sitemap.md for the Vercel documentation.
In the following snippet, a table of contents is created to show the LLM all paths where it can retrieve more information in markdown:
Copy link to headingTest it out
You can now use curl to receive different response types of your content.