If API documentation is to stay in sync with code, AI should operate on two layers: OpenAPI or GraphQL as the source of truth, and narrative documentation such as guides, quickstarts and authentication descriptions, as Intellowork suggests. According to DIDWW, it's also advisable to feed the model additional supporting files like `llms.txt`, `llms-full.txt` and links to relevant pages, rather than relying on a single description without context.
This separation matters because AI organizes content well but should not guess the API contract. In practice this means the generator should extract endpoint names, parameters, data types, response codes and schemas from the OpenAPI definition, and explanatory text should be added by a human or an agent working with the full context.
According to DIDWW, before generating documentation you must provide the model with the environment, authentication mode, delivery method, programming language and the SDK in use. The same guidance recommends testing generated requests in a sandbox before production use.
A practical flow looks like this:
According to the practices described in the Skills Directory, each documentation entry should include the signature, parameters, responses, errors, statuses and at least one realistic request/response example. That helps both manual review and automatic validation by the generator.
The greatest value of AI in maintaining documentation is that it can detect gaps between code and description and propose updates after changes to endpoints, parameters or response formats. Hostkey describes an approach where API documentation is produced as a pipeline of separate stages: indexing, extraction, generation, validation and monitoring, and the LLM receives already ordered data and creates the final Markdown from that.
Following the same approach and the Skills Directory practices, keep these three conditions in mind:
The most common issue is a mismatch between the description and the actual behavior of an endpoint. If the model generates an example without checking statuses, field types or authorization requirements, the documentation becomes visually appealing but operationally useless. DIDWW emphasizes the need to provide technical context and to test generated requests in a sandbox.
A second risk is mixing the reference layer with the descriptive layer. Intellowork distinguishes machine-readable documentation, meaning the OpenAPI/GraphQL specification, from narrative documentation, meaning guides and explanations. That separation helps avoid situations where AI adds “nice” text to an incorrect contract.
Lub System helps B2B companies implement AI, automation and IT solutions end-to-end - from strategy to deployment. See our services or get in touch to discuss your case.
Source: https://doc.didww.com/otp-verification/ai-best-practices.html