GitDocAI provides powerful AI endpoints to help you generate, refine, and enrich your documentation programmatically. Whether you are bootstrapping a new project from a prompt, refining existing paragraphs, or generating custom assets, these tools streamline your content creation workflow.
All AI endpoints require a valid API key passed in the Authorization header as a Bearer token. Ensure your organization has sufficient AI credits before making bulk requests.
AI Endpoints Overview
| Capability | Method | Endpoint Path |
|---|---|---|
| Initialize from AI | POST | /v1/documentation/{organization_id}/{documentation_id}/initialize-from-ai |
| Edit Content | POST | /documentation/{organization_id}/{documentation_id}/ai/edit |
| Generate Image | POST | /documentation/{organization_id}/{documentation_id}/ai/generate-image |
Core AI Workflows
1. Bootstrapping Documentation
If you have an empty documentation project, you can use the AI initialization endpoint to generate a complete scaffold based on a descriptive prompt.
curl -X POST "https://api.gitdocai.com/v1/documentation/org_123/doc_456/initialize-from-ai"
-H "Authorization: Bearer YOUR_API_KEY"
-H "Content-Type: application/json"
-d '{
"prompt": "Create a developer guide for a REST API that manages a bookstore, including authentication, listing books, and processing orders."
}'2. Refining Content
The AI edit endpoint acts as your programmatic copyeditor. You can pass existing markdown content along with specific instructions (e.g., "make this sound more professional", "translate to Spanish", or "fix grammatical errors").
curl -X POST "https://api.gitdocai.com/documentation/org_123/doc_456/ai/edit"
-H "Authorization: Bearer YOUR_API_KEY"
-H "Content-Type: application/json"
-d '{
"content": "the api returns a 200 when it works good.",
"instruction": "Improve grammar and make the tone professional."
}'3. Generating Images
Visuals make documentation much easier to digest. The image generation endpoint allows you to create custom diagrams or illustrations. GitDocAI automatically stores the generated image as an asset within your documentation workspace and returns the asset details so you can immediately embed it in your pages.
Be as descriptive as possible in your image prompts. Specify the style (e.g., "flat vector illustration", "minimalist isometric diagram") for the best results.
4. Managing Assets and Resources
Because the generate-image endpoint automatically saves the resulting file to your documentation's asset library, you may need to retrieve, update, or delete these files. You can manage all documentation assets and file resources using the following endpoints:
| Capability | Method | Endpoint Path |
|---|---|---|
| Get all assets | GET | /v1/documentation/{organization_id}/{documentation_id}/asset |
| Upload an asset | POST | /v1/documentation/{organization_id}/{documentation_id}/asset |
| Get asset by ID | GET | /v1/documentation/{organization_id}/{documentation_id}/asset/{asset_id} |
| Update asset metadata | PUT | /v1/documentation/{organization_id}/{documentation_id}/asset/{asset_id} |
| Delete an asset | DELETE | /v1/documentation/{organization_id}/{documentation_id}/asset/{asset_id} |
| Serve asset file | GET | /v1/documentation/{organization_id}/{documentation_id}/asset/{asset_id}/file |
| Import asset from URL | POST | /v1/documentation/{organization_id}/{documentation_id}/asset/import |
| Request file upload URL | POST | /v1/documentation/{organization_id}/{documentation_id}/file-resources/upload-url |
| Finalize direct upload | POST | /v1/documentation/{organization_id}/{documentation_id}/file-resources/finalize |
Example: The AI Content Lifecycle
Here is how these endpoints typically interact when building out a new page programmatically:
sequenceDiagram
participant Client
participant API as GitDocAI API
participant AI as AI Engine
Client->>API: POST /initialize-from-ai
API->>AI: Request structure based on prompt
AI-->>API: Returns scaffolded Markdown
API-->>Client: 200 OK (Documentation Created)
Client->>API: POST /ai/edit (Draft text)
API->>AI: Apply formatting/grammar rules
AI-->>API: Returns polished Markdown
API-->>Client: 200 OK (Updated Content)
Client->>API: POST /ai/generate-image
API->>AI: Generate visual asset
AI-->>API: Returns image data
API-->>Client: 200 OK (Asset ID & URL)Putting it all together
Ready to automate your documentation? Follow this standard sequence to build a page from scratch:
- 1
Initialize the project
Call the
initialize-from-aiendpoint with a broad prompt to let GitDocAI generate your folders, sections, and initial entries. - 2
Refine specific entries
Iterate over the generated doc entries. If any section needs a specific tone or expansion, pass the text to the
ai/editendpoint with targeted instructions. - 3
Add visual assets
Identify concepts that need visual explanation. Call
ai/generate-image, retrieve the resulting Asset ID, and inject the markdown image link () into your doc entry.
Additional Organization Endpoints
If you are building custom onboarding or setup flows, you can also manage the documentation wizard progress programmatically:
| Capability | Method | Endpoint Path |
|---|---|---|
| Delete wizard progress | DELETE | /v1/organization/{organization_id}/wizard-progress/{documentation_id} |
Frequently Asked Questions
Do AI image generations count against my storage limits?
Yes. Because the generate-image endpoint automatically saves the resulting file to your documentation's asset library, the file size will count toward your organization's total storage quota.
Can I use the edit endpoint on non-Markdown text?
While the endpoint is optimized for Markdown (and will preserve your formatting), you can pass plain text or HTML. However, the AI will generally return the refined content in Markdown format.
What happens if the AI initialization fails?
If the AI times out or fails to generate a scaffold, the API will return a 4xx or 5xx error, and your documentation state will remain unchanged. You will not be charged AI credits for failed generations.