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.
First, create a Route Handler that returns markdown responses when it is requested:
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:
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:
You can now use curl to receive different response types of your content.