└── docs └── api ├── 0-overview.md ├── 0-tune ├── 0-tune.md ├── 1-create.md ├── 2-retrieve.md ├── 4-list.md ├── 5-delete.md └── _category_.json ├── 05-flux-api.md ├── 1-prompt ├── 0-prompt.md ├── 1-create.md ├── 2-retrieve.md ├── 4-list.md ├── 5-delete.md └── _category_.json ├── 2-pack ├── 0-pack.md ├── 1-list.md ├── 2-tunes │ ├── 0-create.md │ └── _category_.json ├── _category_.json ├── assign_prompts.png └── create_pack.png ├── 20-sdxl-api.md ├── 3-like ├── 0-create.md ├── 1-delete.md └── _category_.json ├── 4-images ├── 1-inspect.md └── _category_.json ├── 5-themes ├── 1-create.md └── _category_.json └── _category_.json /docs/api/0-overview.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Overview 3 | --- 4 | 5 | # Astria Fine-tuning API - Overview 6 | 7 | ## Billing 8 | The API uses account balance just like the web interface. See the [pricing](https://www.astria.ai/pricing) page for more details. 9 | 10 | ## Mock testing 11 | The API allows creating a mock `Tune` object with attribute `branch=fast`. See [Create a tune documentation](https://docs.astria.ai/docs/api/tune/create#branch-optional). API call for creating `fast` tune is free, and subsequent prompt calls will return mock images without incurring any charges. This is useful for testing your integration with the API. 12 | Once you're ready for production, you can [purchase credits](https://www.astria.ai/users/edit#billing) and adjust the quantity on the checkout page to how much you need. 13 | 14 | ## Beta features 15 | Astria maintains backward compatability and avoid making changes that could alter the behavior of the API. However, features marked as BETA are subject to change as we try to improve the product. 16 | 17 | ## Auto top off 18 | To allow your account to work without disruption, top-off feature can be enabled to refill account each time account balance reaches zero. Auto top-off can be enabled in the [billing page](https://www.astria.ai/users/edit#billing). 19 | It is recommended to set the top-off amount to at least a week worth of API calls to avoid hitting the rate limit on top-off - Frequent top-offs can cause credit card charges to fail or bank declines. 20 | 21 | ## Storage 22 | Generated images, training pictures and models, will be automatically deleted 30 days after the training has ended. You may delete the fine-tune object including the trained model, training images, and generated images at any time before using the delete API calls. You may opt-in to automatically [extend model storage](https://www.astria.ai/users/edit#billing) or set the `auto_extend` for [tune](/docs/api/tune/create/). 23 | 24 | 25 | ## Authorization 26 | The API uses bearer `Authorization` headers scheme. API calls should include the header: 27 | 28 | ```text 29 | Authorization: Bearer sd_XXXXXX 30 | ``` 31 | 32 | Find your API key on the [API settings](https://www.astria.ai/users/edit#api) under your account settings. 33 | 34 | 35 | ## REST API 36 | Astria API is built as a REST API. Main resources are `tune` and `prompt` and each one has all the CRUD operations. Prompts are usually used as a nested resource on top of tunes (i.e: `/tunes/:id/prompts`). 37 | 38 | ## Error Codes 39 | 40 | :::tip 41 | Pay attention to 504 error below and turn on idempotency for your account to avoid duplicate objects. 42 | ::: 43 | 44 | `422` - Validation error - Log these errors, specifically the response body, and use an exception tracking system such as Rollbar or Sentry to get notified. Do not retry these requests. 45 | 46 | `429` - Rate limiting - This error might show when using polling. Use callbacks to avoid this. 47 | 48 | `500` - Internal server error - Such requests should be retried with exponential backoff and wait start time of 30 seconds. 49 | 50 | `504` - Gateway timeout - This error indicates that the request processing took more than the 30 seconds which is set as the max request timeout. In most cases the request would probably have been processed and you should avoid retrying it. In order to get the response see Idempotency section 51 | 52 | 53 | ## Idempotency 54 | 55 | Idempotency is a principle in programming which means that the same operation (a request in our case) can be made multiple times without changing the result. This can be useful when a request is interrupted and you want to make sure it is processed only once, and avoid duplicate objects. 56 | 57 | Idempotency can be enabled for the account in the [API settings](https://www.astria.ai/users/edit#api). 58 | 59 | For tunes request with the same `title`, idempotency will return the existing tune object and will not create a new one. This is useful for cases where you want to make sure you don't create duplicate tunes. In this case set the tune title to a unique value such as a UUID which identifies the transaction. 60 | 61 | For prompts request with the same attributes, idempotency will return the existing prompt object and will not create a new one. Prompt attributes considered for the idempotency are `text, tune_id, cfg_scale, steps, seed, callback, negative_prompt, super_resolution, face_correct, ar, num_images, controlnet, denoising_strength, use_lpw, controlnet_conditioning_scale, w, h, hires_fix, scheduler, controlnet_txt2img, inpaint_faces` 62 | 63 | When retrying a 504 error, and idempotency is enabled, make sure to wait 60 seconds before retrying the request to allow the previous request to finish processing. 64 | 65 | ## Callbacks 66 | 67 | Callbacks for prompts and tunes are `POST` requests containing the entity object in the request body. Callbacks work in test mode with `branch=fast`. Callbacks are currently not retried if they fail. To test your callbacks, we recommend a local tunnel tool like [ngrok](https://ngrok.com/). If you need your backend server to receive some context arguments/metadata for the callback, like internal user-id or transaction id, we recommend adding those to the callback query string. 68 | -------------------------------------------------------------------------------- /docs/api/0-tune/0-tune.md: -------------------------------------------------------------------------------- 1 | # The tune object 2 | Tune (or Fine-tune) represents a model that is created using training images to learn a new concept or subject. At its core a fine-tune is a neural-network weights file (usually weights 2GB) and contains the information of the trained images. 3 | A fine-tune model can be of various types (checkpoint or lora) and can be used to create prompts which will in turn generate images. 4 | -------------------------------------------------------------------------------- /docs/api/0-tune/1-create.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Create a tune 3 | hide_table_of_contents: true 4 | --- 5 | 6 | import Tabs from '@theme/Tabs'; 7 | import TabItem from '@theme/TabItem'; 8 | 9 |
10 |
11 | 12 | Creates a new fine-tune model from training images which in turn will be used to create prompts and generate images. 13 | 14 | ### Parameters 15 | 16 | #### `name` (required) 17 | A class name the describes the fine-tune. e.g: `man`, `woman`, `cat`, `dog`, `boy`, `girl`, `style` 18 | 19 | #### `title` (required) 20 | Describes the fine-tune. Ideally a UUID related to the transaction. See [idempotency](/docs/api/overview) for more information. 21 | 22 | #### `images` (required) 23 | An array of images to train the fine-tune with. The images can be uploaded as multipart/form-data or as image_urls. 24 | 25 | #### `image_urls` (required) 26 | An array of images to train the fine-tune with. The images can be uploaded as multipart/form-data or as image_urls. 27 | 28 | #### `callback` (optional) 29 | A webhook URL to be called when the tune is finished training. The webhook will receive a POST request with the tune object. See [more on callbacks](/docs/api/overview#callbacks). 30 | 31 | #### `branch` (optional) 32 | Enum: `sd15`, `sdxl1`, `fast`. Will default to the `base_tune` branch if not specified, or to `sd15` if `base_tune` is not specified. 33 | 34 | :::info 35 | Use `branch=fast` for [mock testing](https://docs.astria.ai/docs/api/overview#mock-testing) 36 | ::: 37 | 38 | #### `steps` (optional) 39 | Training steps. Recommended leaving blank in order to allow better defaults set by the system. 40 | 41 | #### `token` (optional) 42 | Unique short text to which the features will be embedded into. Default `ohwx` for SDXL and `sks` for SD15. 43 | 44 | #### `face_crop` (optional) 45 | Detects faces in training images and augments training set with cropped faces. Defaults to [account setting](https://www.astria.ai/users/edit) 46 | 47 | #### `training_face_correct` (optional) 48 | Enhance training images using GFPGAN. Consider enabling if input image are low quality or low resolution. May result in over-smoothing. 49 | 50 | #### `base_tune_id` (optional) 51 | Training on top of former fine-tune or a different baseline model from the [gallery](https://www.astria.ai/gallery/tunes) (id in the URL). e.g: `690204` - Realistic Vision v5.1 52 | 53 | #### `model_type` (optional) 54 | Enum: `lora`, `pti`, `faceid`, `null` for checkpoint. 55 | For SDXL1 - API will default to `pti` and will ignore `model_type` parameter. 56 | 57 | #### `auto_extend` (optional) 58 | Boolean: `true`, `false`. If `true`, the tune will be automatically extended when it expires. Default is `false`. See [pricing](https://www.astria.ai/pricing). 59 | 60 | #### `preset` (optional) 61 | Enum: `flux-lora-focus`, `flux-lora-portrait`, `flux-lora-fast` see details in the GUI, `null`. See [Flux lora training](/docs/use-cases/flux-finetuning/) for more information. 62 | 63 | #### `characteristics` (optional) 64 | A free-form object that can be used to templatize the prompts text. e.g: `{"eye_color": "blue eyes"}` would than be used in the prompt text as `ohwx woman, {{eye_color}}, holding flowers`. 65 | 66 | #### `prompts_attributes` (optional) 67 | Array of prompts entities with all attributes. See [create prompt](/docs/api/prompt/create) for more information. 68 | 69 | ### Returns 70 | 71 | Returns a tune object if successful which will start training immediately and call callback once training is complete. 72 | 73 |
74 | 75 |
76 | 77 | #### POST /tunes 78 | 79 | 80 | 81 | 82 | ```bash showLineNumbers 83 | # With images as multipart/form-data 84 | # Hard coded tune id of Realistic Vision v5.1 from the gallery - https://www.astria.ai/gallery/tunes 85 | # https://www.astria.ai/gallery/tunes/690204/prompts 86 | curl -X POST -H "Authorization: Bearer $API_KEY" https://api.astria.ai/tunes \ 87 | -F tune[title]="John Doe - UUID - 1234-6789-1234-56789" \ 88 | -F tune[name]=man \ 89 | -F tune[branch]="fast" \ 90 | -F tune[callback]="https://optional-callback-url.com/webhooks/astria?user_id=1&tune_id=1" \ 91 | -F tune[base_tune_id]=690204 \ 92 | -F tune[token]=ohwx \ 93 | -F "tune[prompts_attributes][0][text]=ohwx man on space circa 1979 on cover of time magazine" \ 94 | -F tune[prompts_attributes][0][callback]="https://optional-callback-url.com/webhooks/astria?user_id=1&prompt_id=1&tune_id=1" \ 95 | -F "tune[images][]=@1.jpg" \ 96 | -F "tune[images][]=@2.jpg" \ 97 | -F "tune[images][]=@3.jpg" \ 98 | -F "tune[images][]=@4.jpg" 99 | 100 | # With image_urls as form-data 101 | curl -X POST -H "Authorization: Bearer $API_KEY" https://api.astria.ai/tunes \ 102 | -F tune[title]="Grumpy cat - UUID - 1234-6789-1234-56789" \ 103 | -F tune[name]=cat \ 104 | -F tune[branch]="fast" \ 105 | -F tune[callback]="https://optional-callback-url.com/to-your-service-when-ready?user_id=1&tune_id=1" \ 106 | -F tune[base_tune_id]=690204 \ 107 | -F tune[token]=ohwx \ 108 | -F "tune[image_urls][]=https://i.imgur.com/HLHBnl9.jpeg" \ 109 | -F "tune[image_urls][]=https://i.imgur.com/HLHBnl9.jpeg" \ 110 | -F "tune[image_urls][]=https://i.imgur.com/HLHBnl9.jpeg" \ 111 | -F "tune[image_urls][]=https://i.imgur.com/HLHBnl9.jpeg" 112 | 113 | # As JSON 114 | cat > data.json <<- EOM 115 | { 116 | "tune": { 117 | "title": "Grumpy Cat - UUID - 1234-6789-1234-56789", 118 | "name": "cat", 119 | "branch": "fast", 120 | "callback": "https://optional-callback-url.com/to-your-service-when-ready?user_id=1&tune_id=1", 121 | "image_urls": [ 122 | "https://i.imgur.com/HLHBnl9.jpeg", 123 | "https://i.imgur.com/HLHBnl9.jpeg", 124 | "https://i.imgur.com/HLHBnl9.jpeg", 125 | "https://i.imgur.com/HLHBnl9.jpeg" 126 | ], 127 | "prompts_attributes": [ 128 | { 129 | "text": "ohwx cat in space circa 1979 French illustration", 130 | "callback": "https://optional-callback-url.com/to-your-service-when-ready?user_id=1&tune_id=1&prompt_id=1" 131 | }, 132 | { 133 | "text": "ohwx cat getting into trouble viral meme", 134 | "callback": "https://optional-callback-url.com/to-your-service-when-ready?user_id=1&tune_id=1&prompt_id=1" 135 | } 136 | ] 137 | } 138 | } 139 | EOM 140 | 141 | curl -X POST -H"Content-Type: application/json" -H "Authorization: Bearer $API_KEY" --data @data.json https://api.astria.ai/tunes 142 | ``` 143 | 144 | 145 | 146 | ```javascript 147 | // NodeJS 16 148 | // With image_urls and fetch() 149 | // For NodeJS 18 - do NOT import the below as it is built-in 150 | import fetch from "node-fetch"; 151 | 152 | const API_KEY = 'sd_XXXXXX'; 153 | const DOMAIN = 'https://api.astria.ai'; 154 | 155 | function createTune() { 156 | let options = { 157 | method: 'POST', 158 | headers: { 'Authorization': 'Bearer ' + API_KEY, 'Content-Type': 'application/json' }, 159 | body: JSON.stringify({ 160 | tune: { 161 | "title": 'John Doe - UUID - 1234-6789-1234-56789', 162 | // Hard coded tune id of Realistic Vision v5.1 from the gallery - https://www.astria.ai/gallery/tunes 163 | // https://www.astria.ai/gallery/tunes/690204/prompts 164 | "base_tune_id": 690204, 165 | "name": "cat", 166 | "branch": "fast", 167 | "image_urls": [ 168 | "https://i.imgur.com/HLHBnl9.jpeg", 169 | "https://i.imgur.com/HLHBnl9.jpeg", 170 | "https://i.imgur.com/HLHBnl9.jpeg", 171 | "https://i.imgur.com/HLHBnl9.jpeg" 172 | ], 173 | "prompts_attributes": [ 174 | { 175 | "text": "ohwx cat in space circa 1979 French illustration", 176 | "callback": "https://optional-callback-url.com/to-your-service-when-ready?user_id=1&tune_id=1&prompt_id=1" 177 | }, 178 | { 179 | "text": "ohwx cat getting into trouble viral meme", 180 | "callback": "https://optional-callback-url.com/to-your-service-when-ready?user_id=1&tune_id=1&prompt_id=2" 181 | } 182 | ] 183 | } 184 | }) 185 | }; 186 | return fetch(DOMAIN + '/tunes', options) 187 | .then(r => r.json()) 188 | .then(r => console.log(r)) 189 | } 190 | 191 | createTune() 192 | 193 | 194 | /// With form-data, fetch() and nested prompts 195 | // For NodeJS 18 - do NOT import the two below as they are built-in 196 | import fetch from "node-fetch"; 197 | import FormData from 'form-data'; 198 | import fs from 'fs'; 199 | 200 | const API_KEY = 'sd_XXXX'; 201 | const DOMAIN = 'https://api.astria.ai'; 202 | function createTune() { 203 | let formData = new FormData(); 204 | formData.append('tune[title]', 'John Doe - UUID - 1234-6789-1234-56789'); 205 | // formData.append('tune[branch]', 'fast'); 206 | // Hard coded tune id of Realistic Vision v5.1 from the gallery - https://www.astria.ai/gallery/tunes 207 | // https://www.astria.ai/gallery/tunes/690204/prompts 208 | formData.append('tune[base_tune_id]', 690204); 209 | formData.append('tune[name]', 'man'); 210 | formData.append('tune[prompts_attributes][0][callback]', 'https://optional-callback-url.com/to-your-service-when-ready?user_id=1&tune_id=1&prompt_id=1'); 211 | formData.append('tune[prompts_attributes][0][input_image]', fs.createReadStream(`./samples/pose.png`)); 212 | formData.append('tune[prompts_attributes][0][text]',"ohwx man inside spacesuit in space") 213 | // Load all JPGs from ./samples directory and append to FormData 214 | let files = fs.readdirSync('./samples'); 215 | files.forEach(file => { 216 | if(file.endsWith('.jpg')) { 217 | formData.append('tune[images][]', fs.createReadStream(`./samples/${file}`), file); 218 | } 219 | }); 220 | formData.append('tune[callback]', 'https://optional-callback-url.com/to-your-service-when-ready?user_id=1&tune_id=1'); 221 | 222 | let options = { 223 | method: 'POST', 224 | headers: { 225 | 'Authorization': 'Bearer ' + API_KEY 226 | }, 227 | body: formData 228 | }; 229 | return fetch(DOMAIN + '/tunes', options) 230 | .then(r => r.json()) 231 | .then(r => console.log(r)); 232 | } 233 | 234 | createTune(); 235 | 236 | ``` 237 | 238 | 239 | 240 | ```python 241 | import requests 242 | headers = {'Authorization': f'Bearer {API_KEY}'} 243 | 244 | def load_image(file_path): 245 | with open(file_path, "rb") as f: 246 | return f.read() 247 | 248 | # Assuming `prompts` and `tune.images` are already defined in your context 249 | 250 | image_data = load_image("assets/image.jpeg") 251 | 252 | data = { 253 | "tune[title]": "John Doe - UUID - 1234-6789-1234-56789", 254 | "tune[name]": "man", 255 | "tune[base_tune_id]": 690204, 256 | "tune[branch]": "fast", 257 | "tune[token]": "ohwx" 258 | } 259 | files = [] 260 | for i, prompt in enumerate(prompts): 261 | data.update({ 262 | f"tune[prompts_attributes][{i}][text]": prompt['text'], 263 | f"tune[prompts_attributes][{i}][negative_prompt]": prompt['negative_prompt'], 264 | f"tune[prompts_attributes][{i}][face_correct]": "true", 265 | f"tune[prompts_attributes][{i}][inpaint_faces]": "true", 266 | f"tune[prompts_attributes][{i}][super_resolution]": "true", 267 | }) 268 | if prompt['image_data']: 269 | data.update({ 270 | f"tune[prompts_attributes][{i}][controlnet]" : prompt['controlnet'], 271 | }) 272 | files.append((f"tune[prompts_attributes][{i}][input_image]", load_image(prompt['input_image']))) 273 | 274 | for image in tune.images: 275 | image_data = load_image(image) # Assuming image is a file path 276 | files.append(("tune[images][]", image_data)) 277 | 278 | API_URL = 'https://api.astria.ai/tunes' 279 | response = requests.post(API_URL, data=data, files=files, headers=headers) 280 | response.raise_for_status() 281 | 282 | ``` 283 | 284 | 285 | 286 | #### Response 287 | 288 | ```json 289 | 290 | { 291 | "id": 1, 292 | "title": "John Doe - UUID - 1234-6789-1234-56789", 293 | "name": "woman", 294 | "token": "ohwx", 295 | "base_tune_id": null, 296 | "args": null, 297 | "steps": null, 298 | "face_crop": null, 299 | "training_face_correct": false, 300 | "ckpt_url": "https://sdbooth2-production.s3.amazonaws.com/mock", 301 | "ckpt_urls": [ 302 | "https://sdbooth2-production.s3.amazonaws.com/mock" 303 | ], 304 | "eta": "2023-10-02T14:32:40.363Z", 305 | "trained_at": "2023-10-02T14:32:40.363Z", 306 | "started_training_at": "2023-10-02T14:32:05.229Z", 307 | "expires_at": "2023-11-01T14:32:40.363Z", 308 | "created_at": "2023-10-02T14:32:05.067Z", 309 | "branch": "sdxl1", 310 | "model_type": "lora", 311 | "updated_at": "2023-10-02T14:32:40.363Z", 312 | "url": "https://www.astria.ai/tunes/788416.json", 313 | "orig_images": [ 314 | "https://sdbooth2-production.s3.amazonaws.com/mock", 315 | "https://sdbooth2-production.s3.amazonaws.com/mock", 316 | "https://sdbooth2-production.s3.amazonaws.com/mock", 317 | "https://sdbooth2-production.s3.amazonaws.com/mock", 318 | "https://sdbooth2-production.s3.amazonaws.com/mock", 319 | "https://sdbooth2-production.s3.amazonaws.com/mock", 320 | "https://sdbooth2-production.s3.amazonaws.com/mock", 321 | "https://sdbooth2-production.s3.amazonaws.com/mock", 322 | "https://sdbooth2-production.s3.amazonaws.com/mock", 323 | "https://sdbooth2-production.s3.amazonaws.com/mock" 324 | ] 325 | } 326 | ``` 327 |
328 |
329 | 330 | -------------------------------------------------------------------------------- /docs/api/0-tune/2-retrieve.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Retrieve a tune 3 | hide_table_of_contents: true 4 | --- 5 | 6 | import Tabs from '@theme/Tabs'; 7 | import TabItem from '@theme/TabItem'; 8 | 9 |
10 |
11 | 12 | ### Parameters 13 | 14 | No parameters 15 | 16 | ### Returns 17 | 18 | Returns the Tune object. 19 | 20 |
21 | 22 |
23 | 24 | #### GET /tunes/:id 25 | 26 | 27 | 28 | ```bash showLineNumbers 29 | curl -X GET -H "Authorization: Bearer $API_KEY" https://api.astria.ai/tunes/1 30 | ``` 31 | 32 | 33 | 34 | 35 | ```javascript showLineNumbers 36 | const headers = { Authorization: `Bearer ${API_KEY}` } 37 | fetch('https://api.astria.ai/tunes/1', { headers: headers }); 38 | ``` 39 | 40 | 41 | 42 | 43 | ```python showLineNumbers 44 | import requests 45 | headers = {'Authorization': f'Bearer {API_KEY}'} 46 | requests.get('https://api.astria.ai/tunes/1') 47 | ``` 48 | 49 | 50 | 51 | 52 | #### Response 53 | ```json 54 | { 55 | "id": 1, 56 | "title": "John Doe", 57 | "name": "woman", 58 | "token": "ohwx", 59 | "base_tune_id": null, 60 | "args": null, 61 | "steps": null, 62 | "face_crop": null, 63 | "ckpt_url": "https://sdbooth2-production.s3.amazonaws.com/mock", 64 | "ckpt_urls": [ 65 | "https://sdbooth2-production.s3.amazonaws.com/mock" 66 | ], 67 | "trained_at": "2023-10-02T14:32:40.363Z", 68 | "started_training_at": "2023-10-02T14:32:05.229Z", 69 | "expires_at": "2023-11-01T14:32:40.363Z", 70 | "created_at": "2023-10-02T14:32:05.067Z", 71 | "branch": "sdxl1", 72 | "model_type": "lora", 73 | "updated_at": "2023-10-02T14:32:40.363Z", 74 | "url": "https://www.astria.ai/tunes/788416.json", 75 | "orig_images": [ 76 | "https://sdbooth2-production.s3.amazonaws.com/mock", 77 | "https://sdbooth2-production.s3.amazonaws.com/mock", 78 | "https://sdbooth2-production.s3.amazonaws.com/mock", 79 | "https://sdbooth2-production.s3.amazonaws.com/mock", 80 | "https://sdbooth2-production.s3.amazonaws.com/mock", 81 | "https://sdbooth2-production.s3.amazonaws.com/mock", 82 | "https://sdbooth2-production.s3.amazonaws.com/mock", 83 | "https://sdbooth2-production.s3.amazonaws.com/mock", 84 | "https://sdbooth2-production.s3.amazonaws.com/mock", 85 | "https://sdbooth2-production.s3.amazonaws.com/mock" 86 | ] 87 | } 88 | ``` 89 |
90 |
91 | 92 | -------------------------------------------------------------------------------- /docs/api/0-tune/4-list.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: List all tunes 3 | hide_table_of_contents: true 4 | --- 5 | 6 | import Tabs from '@theme/Tabs'; 7 | import TabItem from '@theme/TabItem'; 8 | 9 |
10 |
11 | 12 | ### Parameters 13 | 14 | #### `offset` (optional) 15 | Starting offset for the list of prompts. Default: 0. Current page size is 20. 16 | 17 | ### Returns 18 | 19 | An array of all fine-tunes owned by the authenticated user 20 |
21 | 22 |
23 | 24 | #### GET /tunes 25 | 26 | 27 | 28 | ```bash showLineNumbers 29 | curl -X GET -H "Authorization: Bearer $API_KEY" https://api.astria.ai/tunes 30 | ``` 31 | 32 | 33 | 34 | 35 | ```javascript showLineNumbers 36 | const headers = { Authorization: `Bearer ${API_KEY}` } 37 | fetch('https://api.astria.ai/tunes', { headers: headers }); 38 | ``` 39 | 40 | 41 | 42 | ```python showLineNumbers 43 | import requests 44 | headers={'Authorization': f'Bearer {API_KEY}'} 45 | requests.get('https://api.astria.ai/tunes', headers=headers) 46 | ``` 47 | 48 | 49 | 50 | 51 | #### Response 52 | ```json 53 | 54 | [ 55 | { 56 | "id": 1, 57 | "title": "John Doe", 58 | "name": "woman", 59 | "token": "ohwx", 60 | "base_tune_id": null, 61 | "args": null, 62 | "steps": null, 63 | "face_crop": null, 64 | "ckpt_url": "https://sdbooth2-production.s3.amazonaws.com/mock", 65 | "ckpt_urls": [ 66 | "https://sdbooth2-production.s3.amazonaws.com/mock" 67 | ], 68 | "trained_at": "2023-10-02T14:32:40.363Z", 69 | "started_training_at": "2023-10-02T14:32:05.229Z", 70 | "expires_at": "2023-11-01T14:32:40.363Z", 71 | "created_at": "2023-10-02T14:32:05.067Z", 72 | "branch": "sdxl1", 73 | "model_type": "lora", 74 | "updated_at": "2023-10-02T14:32:40.363Z", 75 | "url": "https://www.astria.ai/tunes/788416.json", 76 | "orig_images": [ 77 | "https://sdbooth2-production.s3.amazonaws.com/mock", 78 | "https://sdbooth2-production.s3.amazonaws.com/mock", 79 | "https://sdbooth2-production.s3.amazonaws.com/mock", 80 | "https://sdbooth2-production.s3.amazonaws.com/mock", 81 | "https://sdbooth2-production.s3.amazonaws.com/mock", 82 | "https://sdbooth2-production.s3.amazonaws.com/mock", 83 | "https://sdbooth2-production.s3.amazonaws.com/mock", 84 | "https://sdbooth2-production.s3.amazonaws.com/mock", 85 | "https://sdbooth2-production.s3.amazonaws.com/mock", 86 | "https://sdbooth2-production.s3.amazonaws.com/mock" 87 | ] 88 | }, 89 | { 90 | "id": 775459, 91 | "title": "Marry Jane", 92 | "name": null, 93 | "is_api": false, 94 | "token": "ohwx", 95 | "base_tune_id": null, 96 | "args": null, 97 | "steps": null, 98 | "face_crop": null, 99 | "ckpt_url": "https://sdbooth2-production.s3.amazonaws.com/mock", 100 | "ckpt_urls": [ 101 | "https://sdbooth2-production.s3.amazonaws.com/mock" 102 | ], 103 | "trained_at": "2023-09-23T16:07:49.137Z", 104 | "started_training_at": "2023-09-23T16:07:37.334Z", 105 | "expires_at": "2023-10-23T16:07:49.137Z", 106 | "created_at": "2023-09-23T16:07:36.606Z", 107 | "branch": "sdxl1", 108 | "model_type": "lora", 109 | "updated_at": "2023-09-23T16:07:49.138Z", 110 | "url": "https://www.astria.ai/tunes/775459.json", 111 | "orig_images": [ 112 | "https://sdbooth2-production.s3.amazonaws.com/mock", 113 | "https://sdbooth2-production.s3.amazonaws.com/mock", 114 | "https://sdbooth2-production.s3.amazonaws.com/mock", 115 | "https://sdbooth2-production.s3.amazonaws.com/mock", 116 | "https://sdbooth2-production.s3.amazonaws.com/mock", 117 | "https://sdbooth2-production.s3.amazonaws.com/mock", 118 | "https://sdbooth2-production.s3.amazonaws.com/mock", 119 | "https://sdbooth2-production.s3.amazonaws.com/mock", 120 | "https://sdbooth2-production.s3.amazonaws.com/mock" 121 | ] 122 | } 123 | ] 124 | ``` 125 |
126 |
127 | -------------------------------------------------------------------------------- /docs/api/0-tune/5-delete.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Delete a tune 3 | hide_table_of_contents: true 4 | --- 5 | 6 | import Tabs from '@theme/Tabs'; 7 | import TabItem from '@theme/TabItem'; 8 | 9 |
10 |
11 | 12 | Deletes a specific tune by its ID, and associated prompts in case of a checkpoint. 13 | 14 | ### Parameters 15 | 16 | #### `id` (required) 17 | The ID of the tune to be deleted. 18 | 19 | ### Returns 20 | 21 | Returns 200 OK if the prompt was successfully deleted. 22 | 23 |
24 | 25 |
26 | 27 | #### DELETE /tunes/:id 28 | 29 | 30 | 31 | ```bash showLineNumbers 32 | curl -X DELETE -H "Authorization: Bearer $API_KEY" https://api.astria.ai/tunes/1 33 | ``` 34 | 35 | 36 | 37 | 38 | ```javascript showLineNumbers 39 | const headers = { Authorization: `Bearer ${API_KEY}` } 40 | fetch('https://api.astria.ai/tunes/1', { 41 | method: 'DELETE', 42 | headers: headers 43 | }); 44 | ``` 45 | 46 | 47 | 48 | 49 | ```python showLineNumbers 50 | import requests 51 | headers = {'Authorization': f'Bearer {API_KEY}'} 52 | requests.delete('https://api.astria.ai/tunes/1', headers=headers) 53 | ``` 54 | 55 | 56 | 57 | 58 | #### Response 59 | `200 OK` 60 |
61 |
62 | -------------------------------------------------------------------------------- /docs/api/05-flux-api.md: -------------------------------------------------------------------------------- 1 | --- 2 | hide_table_of_contents: true 3 | tags: ["flux", "api", "training", "fine-tuning", "lora"] 4 | image: ../use-cases/img/ai-photoshoot-output.jpg 5 | --- 6 | 7 | import Tabs from '@theme/Tabs'; 8 | import TabItem from '@theme/TabItem'; 9 | 10 | 11 | # Flux API usage 12 | 13 | For an overview of Flux fine-tuning, see [Flux fine-tuning](/docs/use-cases/flux-finetuning/) 14 | 15 |
16 |
17 | 18 | * Unlike SD15 checkpoint training, Flux is trained as a LoRA model type. As such, inference is taking place on a base model such as Flux1.dev and `prompt.text` should specify the loaded lora such as `` - will load lora with id=123456 and strength=1 19 | * Flux1.Dev requires commercial license which Astria provides to its customers, and as such LoRA downloading is not available for API usage. 20 | 21 | See [LoRA docs](/docs/features/lora) on lora syntax 22 | 23 | 24 | :::info 25 | To avoid cloning inference details of different model types such as Flux LoRA vs SD1.5 checkpoint, please consider using the [Packs API](/docs/api/pack/pack/). Packs will help you abstract the inference logic so that you do not have to hard-code prompts and parameters such as `w,h, cfg_scale` in your backend. Moreover this will allow the creative department to launch packs, make modifications and even track likes, without needing to touch the backend code. 26 | ::: 27 | 28 |
29 |
30 | 31 | ### Step 1: Fine-tune a lora model 32 | #### POST /tunes 33 | 34 | 35 | 36 | 37 | ```bash showLineNumbers 38 | # With images as multipart/form-data 39 | # Hard coded tune id of Flux1.dev from the gallery - https://www.astria.ai/gallery/tunes 40 | # https://www.astria.ai/gallery/tunes/1504944/prompts 41 | curl -X POST -H "Authorization: Bearer $API_KEY" https://api.astria.ai/tunes \ 42 | -F tune[title]="John Doe - UUID - 1234-6789-1234-56789" \ 43 | -F tune[name]=man \ 44 | -F tune[preset]=flux-lora-portrait \ 45 | -F tune[callback]="https://optional-callback-url.com/webhooks/astria?user_id=1&tune_id=1" \ 46 | -F tune[base_tune_id]=1504944 \ 47 | -F tune[model_type]="lora" \ 48 | -F "tune[images][]=@1.jpg" \ 49 | -F "tune[images][]=@2.jpg" \ 50 | -F "tune[images][]=@3.jpg" \ 51 | -F "tune[images][]=@4.jpg" 52 | 53 | # With image_urls as form-data 54 | curl -X POST -H "Authorization: Bearer $API_KEY" https://api.astria.ai/tunes \ 55 | -F tune[title]="Grumpy cat - UUID - 1234-6789-1234-56789" \ 56 | -F tune[name]=cat \ 57 | -F tune[preset]=flux-lora-portrait \ 58 | -F tune[callback]="https://optional-callback-url.com/to-your-service-when-ready?user_id=1&tune_id=1" \ 59 | -F tune[base_tune_id]=1504944 \ 60 | -F tune[model_type]="lora" \ 61 | -F "tune[image_urls][]=https://i.imgur.com/HLHBnl9.jpeg" \ 62 | -F "tune[image_urls][]=https://i.imgur.com/HLHBnl9.jpeg" \ 63 | -F "tune[image_urls][]=https://i.imgur.com/HLHBnl9.jpeg" \ 64 | -F "tune[image_urls][]=https://i.imgur.com/HLHBnl9.jpeg" 65 | 66 | # As JSON 67 | cat > data.json <<- EOM 68 | { 69 | "tune": { 70 | "title": "Grumpy Cat - UUID - 1234-6789-1234-56789", 71 | "name": "cat", 72 | "base_tune_id": 1504944, 73 | "model_type": "lora", 74 | "callback": "https://optional-callback-url.com/to-your-service-when-ready?user_id=1&tune_id=1", 75 | "image_urls": [ 76 | "https://i.imgur.com/HLHBnl9.jpeg", 77 | "https://i.imgur.com/HLHBnl9.jpeg", 78 | "https://i.imgur.com/HLHBnl9.jpeg", 79 | "https://i.imgur.com/HLHBnl9.jpeg" 80 | ] 81 | } 82 | } 83 | EOM 84 | 85 | curl -X POST -H"Content-Type: application/json" -H "Authorization: Bearer $API_KEY" --data @data.json https://api.astria.ai/tunes 86 | ``` 87 | 88 | 89 | 90 | ```javascript 91 | // NodeJS 16 92 | // With image_urls and fetch() 93 | // For NodeJS 18 - do NOT import the below as it is built-in 94 | import fetch from "node-fetch"; 95 | 96 | const API_KEY = 'sd_XXXXXX'; 97 | const DOMAIN = 'https://api.astria.ai'; 98 | 99 | function createTune() { 100 | let options = { 101 | method: 'POST', 102 | headers: { 'Authorization': 'Bearer ' + API_KEY, 'Content-Type': 'application/json' }, 103 | body: JSON.stringify({ 104 | tune: { 105 | "title": 'John Doe - UUID - 1234-6789-1234-56789', 106 | // Hard coded tune id of Flux1.dev from the gallery - https://www.astria.ai/gallery/tunes 107 | // https://www.astria.ai/gallery/tunes/1504944/prompts 108 | "base_tune_id": 1504944, 109 | "model_type": "lora", 110 | "name": "cat", 111 | "preset": "flux-lora-portrait", 112 | "image_urls": [ 113 | "https://i.imgur.com/HLHBnl9.jpeg", 114 | "https://i.imgur.com/HLHBnl9.jpeg", 115 | "https://i.imgur.com/HLHBnl9.jpeg", 116 | "https://i.imgur.com/HLHBnl9.jpeg" 117 | ], 118 | } 119 | }) 120 | }; 121 | return fetch(DOMAIN + '/tunes', options) 122 | .then(r => r.json()) 123 | .then(r => console.log(r)) 124 | } 125 | 126 | createTune() 127 | 128 | 129 | /// With form-data, fetch() and nested prompts 130 | // For NodeJS 18 - do NOT import the two below as they are built-in 131 | import fetch from "node-fetch"; 132 | import FormData from 'form-data'; 133 | import fs from 'fs'; 134 | 135 | const API_KEY = 'sd_XXXX'; 136 | const DOMAIN = 'https://api.astria.ai'; 137 | function createTune() { 138 | let formData = new FormData(); 139 | formData.append('tune[title]', 'John Doe - UUID - 1234-6789-1234-56789'); 140 | // Hard coded tune id of Flux1.dev from the gallery - https://www.astria.ai/gallery/tunes 141 | // https://www.astria.ai/gallery/tunes/1504944/prompts 142 | formData.append('tune[base_tune_id]', 1504944); 143 | formData.append('tune[model_type]', 'lora'); 144 | formData.append('tune[name]', 'man'); 145 | formData.append('tune[preset]', 'flux-lora-portrait'); 146 | // Load all JPGs from ./samples directory and append to FormData 147 | let files = fs.readdirSync('./samples'); 148 | files.forEach(file => { 149 | if(file.endsWith('.jpg')) { 150 | formData.append('tune[images][]', fs.createReadStream(`./samples/${file}`), file); 151 | } 152 | }); 153 | formData.append('tune[callback]', 'https://optional-callback-url.com/to-your-service-when-ready?user_id=1&tune_id=1'); 154 | 155 | let options = { 156 | method: 'POST', 157 | headers: { 158 | 'Authorization': 'Bearer ' + API_KEY 159 | }, 160 | body: formData 161 | }; 162 | return fetch(DOMAIN + '/tunes', options) 163 | .then(r => r.json()) 164 | .then(r => console.log(r)); 165 | } 166 | 167 | createTune(); 168 | 169 | ``` 170 | 171 | 172 | 173 | ```python 174 | import requests 175 | headers = {'Authorization': f'Bearer {API_KEY}'} 176 | 177 | def load_image(file_path): 178 | with open(file_path, "rb") as f: 179 | return f.read() 180 | 181 | # Assuming `prompts` and `tune.images` are already defined in your context 182 | 183 | image_data = load_image("assets/image.jpeg") 184 | 185 | data = { 186 | "tune[title]": "John Doe - UUID - 1234-6789-1234-56789", 187 | "tune[name]": "man", 188 | "tune[preset]": "flux-lora-portrait", 189 | "tune[base_tune_id]": 1504944, 190 | "tune[model_type]": "lora", 191 | } 192 | files = [] 193 | 194 | for image in tune.images: 195 | image_data = load_image(image) # Assuming image is a file path 196 | files.append(("tune[images][]", image_data)) 197 | 198 | API_URL = 'https://api.astria.ai/tunes' 199 | response = requests.post(API_URL, data=data, files=files, headers=headers) 200 | response.raise_for_status() 201 | 202 | ``` 203 | 204 | 205 | 206 | 207 | ### Step 2: Generate images using the fine-tuned model 208 | #### POST /tunes/:id/prompts 209 | 210 | 211 | 212 | 213 | ```bash showLineNumbers 214 | # Note the hard-coded 1504944 which is the tune_id of Flux1.dev from the gallery 215 | curl -X POST -H "Authorization: Bearer $API_KEY" https://api.astria.ai/tunes/1504944/prompts \ 216 | -F prompt[text]=" a painting of ohwx man in the style of Van Gogh" \ 217 | -F prompt[callback]="https://optional-callback-url.com/to-your-service-when-ready?prompt_id=1" 218 | ``` 219 | 220 | 221 | 222 | ```javascript 223 | const fetch = require('node-fetch'); 224 | const FormData = require('form-data'); 225 | 226 | // Note the hard-coded 1504944 which is the tune_id of Flux1.dev from the gallery 227 | const API_URL = 'https://api.astria.ai/tunes/1504944/prompts'; 228 | const API_KEY = 'YOUR_API_KEY'; // Replace with your actual API key 229 | const headers = { Authorization: `Bearer ${API_KEY}` } 230 | 231 | const form = new FormData(); 232 | form.append('prompt[text]', ' a painting of ohwx man in the style of Van Gogh'); 233 | form.append('prompt[callback]', 'https://optional-callback-url.com/to-your-service-when-ready?prompt_id=1'); 234 | 235 | fetch(API_URL, { 236 | method: 'POST', 237 | headers: headers, 238 | body: form 239 | }).then(response => response.json()) 240 | 241 | 242 | ``` 243 | 244 | 245 | 246 | ```python 247 | import requests 248 | 249 | # Note the hard-coded 1504944 which is the tune_id of Flux1.dev from the gallery 250 | API_URL = 'https://api.astria.ai/tunes/1504944/prompts' 251 | API_KEY = 'YOUR_API_KEY' # Replace with your actual API key 252 | 253 | headers = { 254 | 'Authorization': f'Bearer {API_KEY}' 255 | } 256 | 257 | data = { 258 | 'prompt[text]': ' a painting of ohwx man in the style of Van Gogh', 259 | 'prompt[callback]': 'https://optional-callback-url.com/to-your-service-when-ready?prompt_id=1' 260 | } 261 | files = [] 262 | 263 | response = requests.post(API_URL, headers=headers, data=data) 264 | ``` 265 | 266 | 267 | 268 |
269 |
270 | -------------------------------------------------------------------------------- /docs/api/1-prompt/0-prompt.md: -------------------------------------------------------------------------------- 1 | # The prompt object 2 | The prompt object is usually used as a nested resource of tune as prompts are generated using a fine-tune model. A prompt is a text that is used to generate images using a fine-tune model. The prompt object contains the generated images. 3 | -------------------------------------------------------------------------------- /docs/api/1-prompt/1-create.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Create a prompt 3 | hide_table_of_contents: true 4 | --- 5 | 6 | import Tabs from '@theme/Tabs'; 7 | import TabItem from '@theme/TabItem'; 8 | 9 |
10 |
11 | 12 | Creates a new fine-tune model from training images which in turn will be used to create prompts and generate images. 13 | 14 | ### Parameters 15 | 16 | #### `text` (required) 17 | Description of the image. 18 | 19 | #### `negative_prompt` (optional) 20 | A comma separated list of words that should not appear in the image. 21 | 22 | #### `callback` (optional) 23 | a URL that will be called when the prompt is done processing. The callback is a POST request where the body contains the prompt object. See [more](/docs/api/overview#callbacks). 24 | 25 | #### `num_images` (optional) 26 | Number of images to generate. Range: 1-8. 27 | 28 | #### `seed` (optional) 29 | Random number to create consistent results. Range: 0 to 2^32. 30 | 31 | #### `super_resolution` (optional) 32 | Boolean. X4 super-resolution. 33 | 34 | #### `inpaint_faces` (optional) 35 | Boolean. Requires super-resolution on. Inpaints faces. 36 | 37 | #### `hires_fix` (optional) 38 | Boolean. Super resolution details. Available only when super_resolution is true. Adds details. 39 | 40 | #### `face_correct` (optional) 41 | Boolean. Runs another AI model on top to correct the face in the image. 42 | 43 | #### `face_swap` (optional) 44 | Boolean. Uses training images to swap face and enhance resemblance. 45 | 46 | #### `cfg_scale` (optional) 47 | Float. How strictly the diffusion process adheres to the prompt text (higher values keep your image closer to your prompt). Range 0-15 48 | 49 | #### `steps` (optional) 50 | Integer. Number of diffusion steps to run . Range 0-50 51 | 52 | #### `use_lpw` (optional) 53 | Boolean. Use weighted prompts. 54 | 55 | #### `w` (optional) 56 | width - In multiples of 8. 57 | 58 | #### `h` (optional) 59 | height - In multiples of 8. 60 | 61 | #### `scheduler` (optional) 62 | enum: `euler`, `euler_a`, `dpm++2m_karras`, `dpm++sde_karras`, `dpm++2m`, `dpm++sde`, `lcm`, `tcd`. If not specified the default [account scheduler](https://www.astria.ai/users/edit) will be used. 63 | 64 | #### `backend_version` (optional) 65 | enum: null, `1`, If not specified will default to the [account version](https://www.astria.ai/users/edit) will be used. 66 | 67 | #### `style` (optional) 68 | enum: null, `Cinematic`, `Animated`, `Digital Art`, `Photographic`, `Fantasy art`, `Neonpunk`, `Enhance`, `Comic book`, `Lowpoly`, `Line art`. See [more](/docs/features/styles). 69 | 70 | #### `color_grading` (optional) 71 | enum: `Film Velvia`, `Film Portra`, `Ektar`. 72 | 73 | #### `film_grain` (optional) 74 | boolean - Adds noise to the image to make it look more realistic. 75 | 76 | ## Img2Img / ControlNet 77 | 78 | #### `controlnet` (optional) 79 | Requires input_image. Possible values: composition, reference, segroom, ipadapter, lineart, canny, depth, mlsd, hed, pose, tile, qr. 80 | 81 | #### `denoising_strength` (optional) 82 | For img2img. 1.0 - Take prompt. 0.0 - Take image. Range: 0.0-1.0. Default: 0.8 83 | 84 | #### `controlnet_conditioning_scale` (optional) 85 | Strength of controlnet conditioning. 0.0-1.0 86 | 87 | #### `controlnet_txt2img` (optional) 88 | Boolean toggle. True for text to image controlnet. False for image to image controlnet. 89 | 90 | #### `input_image` (optional) 91 | Binary multi-part request with the image. Used in conjunction with controlnet parameter. 92 | 93 | #### `input_image_url` (optional) 94 | URL to an image. Used in conjunction with controlnet parameter. 95 | 96 | #### `mask_image` (optional) 97 | Binary multi-part request with one channel mask image. Used in conjunction with input_image parameter for inpainting 98 | 99 | #### `mask_image_url` (optional) 100 | URL to a one channel mask image. Used in conjunction with input_image_url parameter for inpainting. 101 | 102 | #### `lora_scale` (optional) 103 | Available only when used as `prompts_attributes` in `POST /tunes` request to override the default scale of the LoRA model. 104 | 105 | ### Returns 106 | 107 | Returns a prompt object if successful which will start processing if tune is processed. 108 | 109 |
110 | 111 |
112 | 113 | #### POST /tunes/:id/prompts 114 | 115 | 116 | 117 | 118 | ```bash showLineNumbers 119 | curl -X POST -H "Authorization: Bearer $API_KEY" https://api.astria.ai/tunes/1/prompts \ 120 | -F prompt[text]="a painting of ohwx man in the style of Van Gogh" \ 121 | -F prompt[negative_prompt]="old, blemish, wrin" \ 122 | -F prompt[super_resolution]=true \ 123 | -F prompt[face_correct]=true \ 124 | -F prompt[callback]="https://optional-callback-url.com/to-your-service-when-ready?prompt_id=1" 125 | ``` 126 | 127 | 128 | 129 | ```javascript 130 | const fetch = require(`node-fetch'); 131 | const FormData = require('form-data'); 132 | 133 | const API_URL = 'https://api.astria.ai/tunes/1/prompts'; 134 | const API_KEY = 'YOUR_API_KEY'; // Replace with your actual API key 135 | const headers = { Authorization: `Bearer ${API_KEY}` } 136 | 137 | const form = new FormData(); 138 | form.append('prompt[text]', 'a painting of ohwx man in the style of Van Gogh'); 139 | form.append('prompt[negative_prompt]', 'old, blemish, wrin'); 140 | form.append('prompt[super_resolution]', true); 141 | form.append('prompt[face_correct]', true); 142 | form.append('prompt[callback]', 'https://optional-callback-url.com/to-your-service-when-ready?prompt_id=1'); 143 | 144 | fetch(API_URL, { 145 | method: 'POST', 146 | headers: headers, 147 | body: form 148 | }).then(response => response.json()) 149 | 150 | 151 | ``` 152 | 153 | 154 | 155 | ```python 156 | import requests 157 | 158 | API_URL = 'https://api.astria.ai/tunes/1/prompts' 159 | API_KEY = 'YOUR_API_KEY' # Replace with your actual API key 160 | 161 | headers = { 162 | 'Authorization': f'Bearer {API_KEY}' 163 | } 164 | 165 | data = { 166 | 'prompt[text]': 'a painting of ohwx man in the style of Van Gogh', 167 | 'prompt[negative_prompt]': 'old, blemish, wrin', 168 | 'prompt[super_resolution]': True, 169 | 'prompt[face_correct]': True, 170 | 'prompt[callback]': 'https://optional-callback-url.com/to-your-service-when-ready?prompt_id=1' 171 | } 172 | files = [] 173 | files.append((f"prompt[input_image]", load_image(prompt['input_image']))) 174 | 175 | response = requests.post(API_URL, headers=headers, files=files, data=data) 176 | ``` 177 | 178 | 179 | 180 | #### Response 181 | 182 | ```json 183 | { 184 | "id": 1, 185 | "callback": "https://optional-callback-url.com/to-your-service-when-ready?prompt_id=1", 186 | "text": "a painting of ohwx man in the style of Van Gogh", 187 | "negative_prompt": "old, blemish, wrinkles, mole", 188 | "cfg_scale": null, 189 | "steps": null, 190 | "seed": null, 191 | "trained_at": null, 192 | "started_training_at": null, 193 | "created_at": "2022-10-06T16:12:54.505Z", 194 | "updated_at": "2022-10-06T16:12:54.505Z", 195 | "tune_id": 1, 196 | "url": "http://api.astria.ai/tunes/1/prompts/1.json" 197 | } 198 | ``` 199 |
200 |
201 | 202 | -------------------------------------------------------------------------------- /docs/api/1-prompt/2-retrieve.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Retrieve a prompt 3 | hide_table_of_contents: true 4 | --- 5 | 6 | import Tabs from '@theme/Tabs'; 7 | import TabItem from '@theme/TabItem'; 8 | 9 |
10 |
11 | 12 | ### Parameters 13 | 14 | No parameters 15 | 16 | ### Returns 17 | 18 | Returns the prompt object. 19 | 20 |
21 | 22 |
23 | 24 | #### GET /tunes/:tune_id/prompts/:id 25 | 26 | 27 | 28 | ```bash showLineNumbers 29 | curl -X GET -H "Authorization: Bearer $API_KEY" https://api.astria.ai/tunes/1/prompts/1 30 | ``` 31 | 32 | 33 | 34 | 35 | ```javascript showLineNumbers 36 | const headers = { Authorization: `Bearer ${API_KEY}` } 37 | fetch('https://api.astria.ai/tunes/1/prompts/1', { headers: headers }); 38 | ``` 39 | 40 | 41 | 42 | ```python showLineNumbers 43 | import requests 44 | headers = { 45 | 'Authorization': f'Bearer {API_KEY}' 46 | } 47 | requests.get('https://api.astria.ai/tunes/1/prompts/1', headers=headers) 48 | ``` 49 | 50 | 51 | 52 | #### Response 53 | ```json 54 | { 55 | "id": 1, 56 | "callback": "https://optional-callback-url.com/to-your-service-when-ready", 57 | "text": "a painting of ohwx man in the style of Van Gogh", 58 | "negative_prompt": "old, blemish, wrinkles, mole", 59 | "cfg_scale": null, 60 | "steps": null, 61 | "seed": null, 62 | "trained_at": null, 63 | "started_training_at": null, 64 | "created_at": "2022-10-06T16:12:54.505Z", 65 | "updated_at": "2022-10-06T16:12:54.505Z", 66 | "tune_id": 1, 67 | "url": "http://api.astria.ai/tunes/1/prompts/1.json" 68 | } 69 | ``` 70 |
71 |
72 | 73 | -------------------------------------------------------------------------------- /docs/api/1-prompt/4-list.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: List all prompts 3 | hide_table_of_contents: true 4 | --- 5 | 6 | import Tabs from '@theme/Tabs'; 7 | import TabItem from '@theme/TabItem'; 8 | 9 |
10 |
11 | 12 | ### Parameters 13 | 14 | #### `offset` (optional) 15 | Starting offset for the list of prompts. Default: 0. Current page size is 20. 16 | 17 | ### Returns 18 | 19 | An array of prompts owned by the authenticated user. If used as a nested resource (in the url), will return prompts owned by the tune. 20 |
21 | 22 |
23 | 24 | #### GET /tunes/:id/prompts 25 | 26 | 27 | 28 | ```bash showLineNumbers 29 | curl -X GET -H "Authorization: Bearer $API_KEY" https://api.astria.ai/tunes/1/prompts 30 | ``` 31 | 32 | 33 | 34 | 35 | ```javascript showLineNumbers 36 | const headers = { Authorization: `Bearer ${API_KEY}` } 37 | fetch('https://api.astria.ai/tunes/1/prompts', { headers: headers }); 38 | ``` 39 | 40 | 41 | 42 | ```python showLineNumbers 43 | import requests 44 | headers = {'Authorization': f'Bearer {API_KEY}'} 45 | requests.get('https://api.astria.ai/tunes/1/prompts', headers=headers) 46 | ``` 47 | 48 | 49 | 50 | 51 | #### Response 52 | ```json 53 | 54 | [ 55 | { 56 | "id": 1, 57 | "callback": "https://optional-callback-url.com/to-your-service-when-ready?user_id=your_internal_user_id&transaction_id=internal_transaction_id", 58 | "text": "a painting of ohwx man in the style of Van Gogh", 59 | "negative_prompt": "old, blemish, wrinkles, mole", 60 | "cfg_scale": null, 61 | "steps": null, 62 | "seed": null, 63 | "trained_at": null, 64 | "started_training_at": null, 65 | "created_at": "2022-10-06T16:12:54.505Z", 66 | "updated_at": "2022-10-06T16:12:54.505Z", 67 | "tune_id": 1, 68 | "url": "http://api.astria.ai/tunes/1/prompts/1.json" 69 | } 70 | ] 71 | ``` 72 |
73 |
74 | 75 | -------------------------------------------------------------------------------- /docs/api/1-prompt/5-delete.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Delete a prompt 3 | hide_table_of_contents: true 4 | --- 5 | 6 | import Tabs from '@theme/Tabs'; 7 | import TabItem from '@theme/TabItem'; 8 | 9 |
10 |
11 | 12 | Deletes a specific prompt associated with a tune. 13 | 14 | ### Parameters 15 | 16 | #### `id` (required) 17 | The ID of the prompt to be deleted. 18 | 19 | ### Returns 20 | 21 | Returns 200 OK if the prompt was successfully deleted. 22 | 23 |
24 | 25 |
26 | 27 | #### DELETE /tunes/:tune_id/prompts/:id 28 | 29 | 30 | 31 | 32 | ```bash showLineNumbers 33 | curl -X DELETE -H "Authorization: Bearer $API_KEY" https://api.astria.ai/prompts/1 34 | ``` 35 | 36 | 37 | 38 | 39 | ```javascript showLineNumbers 40 | const fetch = require('node-fetch'); 41 | 42 | const API_URL = 'https://api.astria.ai/prompts/1'; 43 | const API_KEY = 'YOUR_API_KEY'; // Replace with your actual API key 44 | const headers = { Authorization: `Bearer ${API_KEY}` } 45 | 46 | fetch(API_URL, { 47 | method: 'DELETE', 48 | headers: headers 49 | }).then(response => response.json()) 50 | ``` 51 | 52 | 53 | 54 | 55 | ```python showLineNumbers 56 | import requests 57 | 58 | API_URL = 'https://api.astria.ai/prompts/1' 59 | API_KEY = 'YOUR_API_KEY' # Replace with your actual API key 60 | 61 | headers = { 62 | 'Authorization': f'Bearer {API_KEY}' 63 | } 64 | 65 | response = requests.delete(API_URL, headers=headers) 66 | ``` 67 | 68 | 69 | 70 | 71 | #### Response 72 | 73 | ```json 74 | { 75 | "message": "Prompt successfully deleted" 76 | } 77 | ``` 78 | 79 |
80 |
81 | -------------------------------------------------------------------------------- /docs/api/2-pack/0-pack.md: -------------------------------------------------------------------------------- 1 | # The pack object 2 | 3 |