a1c00l commited on
Commit
83decd8
Β·
verified Β·
1 Parent(s): 78cabc3

Update docs/AI_SBOM_API_doc.md

Browse files
Files changed (1) hide show
  1. docs/AI_SBOM_API_doc.md +38 -101
docs/AI_SBOM_API_doc.md CHANGED
@@ -2,7 +2,7 @@
2
 
3
  ## Overview
4
 
5
- The AI SBOM Generator API provides a comprehensive solution for generating CycloneDX-compliant AI Bill of Materials (AIBOM) for Hugging Face models. This document outlines the available API endpoints, their functionality, and how to interact with them using cURL commands.
6
 
7
  ## Base URL
8
 
@@ -37,7 +37,7 @@ curl -X GET "https://aetheris-ai-aibom-generator.hf.space/status"
37
  }
38
  ```
39
 
40
- ### Generate AIBOM Endpoint
41
 
42
  **Purpose**: Generate an AI SBOM for a specified Hugging Face model.
43
 
@@ -62,7 +62,7 @@ curl -X POST "https://aetheris-ai-aibom-generator.hf.space/api/generate" \
62
  }'
63
  ```
64
 
65
- **Expected Response**: JSON containing the generated AIBOM, model ID, timestamp, and download URL.
66
  ```json
67
  {
68
  "aibom": {
@@ -81,7 +81,7 @@ curl -X POST "https://aetheris-ai-aibom-generator.hf.space/api/generate" \
81
  }
82
  ```
83
 
84
- ### Generate AIBOM with Enhancement Report
85
 
86
  **Purpose**: Generate an AI SBOM with a detailed enhancement report.
87
 
@@ -102,7 +102,7 @@ curl -X POST "https://aetheris-ai-aibom-generator.hf.space/api/generate-with-rep
102
  }'
103
  ```
104
 
105
- **Expected Response**: JSON containing the generated AIBOM, model ID, timestamp, download URL, and enhancement report.
106
  ```json
107
  {
108
  "aibom": { ... },
@@ -128,7 +128,7 @@ curl -X POST "https://aetheris-ai-aibom-generator.hf.space/api/generate-with-rep
128
 
129
  ### Get Model Score
130
 
131
- **Purpose**: Get the completeness score for a model without generating a full AIBOM.
132
 
133
  **Endpoint**: `/api/models/{model_id}/score`
134
 
@@ -165,95 +165,16 @@ curl -X GET "https://aetheris-ai-aibom-generator.hf.space/api/models/meta-llama/
165
  }
166
  ```
167
 
168
- ### Batch Generate AIBOMs
169
 
170
- **Purpose**: Start a batch job to generate AIBOMs for multiple models.
171
-
172
- **Endpoint**: `/api/batch`
173
-
174
- **Method**: POST
175
-
176
- **Parameters**:
177
- - `model_ids` (required): List of Hugging Face model IDs to generate AIBOMs for
178
- - `include_inference` (optional): Whether to use AI inference to enhance the AI SBOM (default: true)
179
- - `use_best_practices` (optional): Whether to use industry best practices for scoring (default: true)
180
- - `hf_token` (optional): Hugging Face API token for accessing private models
181
-
182
- **cURL Example**:
183
- ```bash
184
- curl -X POST "https://aetheris-ai-aibom-generator.hf.space/api/batch" \
185
- -H "Content-Type: application/json" \
186
- -d '{
187
- "model_ids": [
188
- "meta-llama/Llama-2-7b-chat-hf",
189
- "google/flan-t5-base"
190
- ],
191
- "include_inference": true,
192
- "use_best_practices": true
193
- }'
194
- ```
195
-
196
- **Expected Response**: JSON containing the batch job ID and status information.
197
- ```json
198
- {
199
- "job_id": "...",
200
- "status": "queued",
201
- "model_ids": [
202
- "meta-llama/Llama-2-7b-chat-hf",
203
- "google/flan-t5-base"
204
- ],
205
- "created_at": "2025-04-24T20:30:00Z"
206
- }
207
- ```
208
-
209
- ### Check Batch Job Status
210
-
211
- **Purpose**: Check the status of a batch job.
212
-
213
- **Endpoint**: `/api/batch/{job_id}`
214
-
215
- **Method**: GET
216
-
217
- **Parameters**:
218
- - `job_id` (path parameter): The ID of the batch job to check
219
-
220
- **cURL Example**:
221
- ```bash
222
- curl -X GET "https://aetheris-ai-aibom-generator.hf.space/api/batch/{job_id}"
223
- ```
224
-
225
- **Expected Response**: JSON containing the current status of the batch job and results for completed models.
226
- ```json
227
- {
228
- "job_id": "...",
229
- "status": "processing",
230
- "model_ids": [
231
- "meta-llama/Llama-2-7b-chat-hf",
232
- "google/flan-t5-base"
233
- ],
234
- "created_at": "2025-04-24T20:30:00Z",
235
- "completed": 1,
236
- "total": 2,
237
- "results": {
238
- "meta-llama/Llama-2-7b-chat-hf": {
239
- "status": "completed",
240
- "download_url": "/output/meta-llama_Llama-2-7b-chat-hf_....json",
241
- "enhancement_report": { ... }
242
- }
243
- }
244
- }
245
- ```
246
-
247
- ### Download Generated AIBOM
248
-
249
- **Purpose**: Download a previously generated AIBOM file.
250
 
251
  **Endpoint**: `/download/{filename}`
252
 
253
  **Method**: GET
254
 
255
  **Parameters**:
256
- - `filename` (path parameter): The filename of the AIBOM to download
257
 
258
  **cURL Example**:
259
  ```bash
@@ -261,11 +182,11 @@ curl -X GET "https://aetheris-ai-aibom-generator.hf.space/download/{filename}" \
261
  -o "downloaded_aibom.json"
262
  ```
263
 
264
- **Expected Response**: The AIBOM JSON file will be downloaded to your local machine.
265
 
266
  ### Form-Based Generation (Web UI)
267
 
268
- **Purpose**: Generate an AIBOM using form data (typically used by the web UI).
269
 
270
  **Endpoint**: `/generate`
271
 
@@ -284,34 +205,48 @@ curl -X POST "https://aetheris-ai-aibom-generator.hf.space/generate" \
284
  -F "use_best_practices=true"
285
  ```
286
 
287
- **Expected Response**: HTML page with the generated AIBOM results.
288
 
289
  ## Web UI
290
 
291
- The API also provides a web user interface for generating AIBOMs without writing code:
292
 
293
  **URL**: `https://aetheris-ai-aibom-generator.hf.space/`
294
 
295
  The web UI allows you to:
296
  1. Enter a Hugging Face model ID
297
  2. Configure generation options
298
- 3. Generate an AIBOM
299
  4. View the results in a human-friendly format
300
- 5. Download the generated AIBOM as a JSON file
301
 
302
  ## Understanding the Field Checklist
303
 
304
  In the Field Checklist tab of the results page, you'll see a list of fields with check marks (βœ”/✘) and stars (β˜…). Here's what they mean:
305
 
306
  - **Check marks**:
307
- - βœ”: Field is present in the AIBOM
308
- - ✘: Field is missing from the AIBOM
309
 
310
  - **Stars** (importance level):
311
- - β˜…β˜…β˜… (three stars): Critical fields - Essential for a valid and complete AIBOM
312
  - β˜…β˜… (two stars): Important fields - Valuable information that enhances completeness
313
  - β˜… (one star): Supplementary fields - Additional context and details (optional)
314
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
315
  ## Notes on Using the API
316
 
317
  1. When deployed on Hugging Face Spaces, use the correct URL format as shown in the examples.
@@ -326,7 +261,9 @@ The API returns standard HTTP status codes:
326
  - 200: Success
327
  - 400: Bad Request (invalid parameters)
328
  - 404: Not Found (resource not found)
 
329
  - 500: Internal Server Error (server-side error)
 
330
 
331
  Error responses include a detail message explaining the error:
332
  ```json
@@ -337,10 +274,10 @@ Error responses include a detail message explaining the error:
337
 
338
  ## Completeness Score
339
 
340
- The completeness score is calculated based on the presence and quality of various fields in the AIBOM. The score is broken down into sections:
341
 
342
- 1. **Required Fields** (20 points): Basic required fields for a valid AIBOM
343
- 2. **Metadata** (20 points): Information about the AIBOM itself
344
  3. **Component Basic Info** (20 points): Basic information about the AI model component
345
  4. **Model Card** (30 points): Detailed model card information
346
  5. **External References** (10 points): Links to external resources
@@ -356,4 +293,4 @@ When AI enhancement is enabled, the API uses an inference model to extract addit
356
  3. **Improvement**: The point increase from enhancement
357
  4. **AI Model Used**: The model used for enhancement
358
 
359
- This helps you understand how much the AI enhancement improved the AIBOM's completeness.
 
2
 
3
  ## Overview
4
 
5
+ The AI SBOM Generator API provides a comprehensive solution for generating CycloneDX-compliant AI Bill of Materials (AI SBOM) for Hugging Face models. This document outlines the available API endpoints, their functionality, and how to interact with them using cURL commands.
6
 
7
  ## Base URL
8
 
 
37
  }
38
  ```
39
 
40
+ ### Generate AI SBOM Endpoint
41
 
42
  **Purpose**: Generate an AI SBOM for a specified Hugging Face model.
43
 
 
62
  }'
63
  ```
64
 
65
+ **Expected Response**: JSON containing the generated AI SBOM, model ID, timestamp, and download URL.
66
  ```json
67
  {
68
  "aibom": {
 
81
  }
82
  ```
83
 
84
+ ### Generate AI SBOM with Enhancement Report
85
 
86
  **Purpose**: Generate an AI SBOM with a detailed enhancement report.
87
 
 
102
  }'
103
  ```
104
 
105
+ **Expected Response**: JSON containing the generated AI SBOM, model ID, timestamp, download URL, and enhancement report.
106
  ```json
107
  {
108
  "aibom": { ... },
 
128
 
129
  ### Get Model Score
130
 
131
+ **Purpose**: Get the completeness score for a model without generating a full AI SBOM.
132
 
133
  **Endpoint**: `/api/models/{model_id}/score`
134
 
 
165
  }
166
  ```
167
 
168
+ ### Download Generated AI SBOM
169
 
170
+ **Purpose**: Download a previously generated AI SBOM file.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
 
172
  **Endpoint**: `/download/{filename}`
173
 
174
  **Method**: GET
175
 
176
  **Parameters**:
177
+ - `filename` (path parameter): The filename of the AI SBOM to download
178
 
179
  **cURL Example**:
180
  ```bash
 
182
  -o "downloaded_aibom.json"
183
  ```
184
 
185
+ **Expected Response**: The AI SBOM JSON file will be downloaded to your local machine.
186
 
187
  ### Form-Based Generation (Web UI)
188
 
189
+ **Purpose**: Generate an AI SBOM using form data (typically used by the web UI).
190
 
191
  **Endpoint**: `/generate`
192
 
 
205
  -F "use_best_practices=true"
206
  ```
207
 
208
+ **Expected Response**: HTML page with the generated AI SBOM results.
209
 
210
  ## Web UI
211
 
212
+ The API also provides a web user interface for generating AI SBOMs without writing code:
213
 
214
  **URL**: `https://aetheris-ai-aibom-generator.hf.space/`
215
 
216
  The web UI allows you to:
217
  1. Enter a Hugging Face model ID
218
  2. Configure generation options
219
+ 3. Generate an AI SBOM
220
  4. View the results in a human-friendly format
221
+ 5. Download the generated AI SBOM as a JSON file
222
 
223
  ## Understanding the Field Checklist
224
 
225
  In the Field Checklist tab of the results page, you'll see a list of fields with check marks (βœ”/✘) and stars (β˜…). Here's what they mean:
226
 
227
  - **Check marks**:
228
+ - βœ”: Field is present in the AI SBOM
229
+ - ✘: Field is missing from the AI SBOM
230
 
231
  - **Stars** (importance level):
232
+ - β˜…β˜…β˜… (three stars): Critical fields - Essential for a valid and complete AI SBOM
233
  - β˜…β˜… (two stars): Important fields - Valuable information that enhances completeness
234
  - β˜… (one star): Supplementary fields - Additional context and details (optional)
235
 
236
+ ## Security Features
237
+
238
+ The API includes several security features to protect against Denial of Service (DoS) attacks:
239
+
240
+ 1. **Rate Limiting**: Limits the number of requests a single IP address can make within a specific time window.
241
+
242
+ 2. **Concurrency Limiting**: Restricts the total number of simultaneous requests being processed to prevent resource exhaustion.
243
+
244
+ 3. **Request Size Limiting**: Prevents attackers from sending extremely large payloads that could consume memory or processing resources.
245
+
246
+ 4. **API Key Authentication** (optional): When configured, requires an API key for accessing API endpoints, enabling tracking and control of API usage.
247
+
248
+ 5. **CAPTCHA Verification** (optional): When configured for the web interface, helps ensure requests come from humans rather than bots.
249
+
250
  ## Notes on Using the API
251
 
252
  1. When deployed on Hugging Face Spaces, use the correct URL format as shown in the examples.
 
261
  - 200: Success
262
  - 400: Bad Request (invalid parameters)
263
  - 404: Not Found (resource not found)
264
+ - 429: Too Many Requests (rate limit exceeded)
265
  - 500: Internal Server Error (server-side error)
266
+ - 503: Service Unavailable (server at capacity)
267
 
268
  Error responses include a detail message explaining the error:
269
  ```json
 
274
 
275
  ## Completeness Score
276
 
277
+ The completeness score is calculated based on the presence and quality of various fields in the AI SBOM. The score is broken down into sections:
278
 
279
+ 1. **Required Fields** (20 points): Basic required fields for a valid AI SBOM
280
+ 2. **Metadata** (20 points): Information about the AI SBOM itself
281
  3. **Component Basic Info** (20 points): Basic information about the AI model component
282
  4. **Model Card** (30 points): Detailed model card information
283
  5. **External References** (10 points): Links to external resources
 
293
  3. **Improvement**: The point increase from enhancement
294
  4. **AI Model Used**: The model used for enhancement
295
 
296
+ This helps you understand how much the AI enhancement improved the AI SBOM's completeness.