# 순서도 생성 및 편집

과학 순서도와 작업 흐름도를 SVG로 만들고 후속 지시로 수정하세요.

출처: https://scifig.ai/ko/docs/api/flowcharts

## JSON 본문

`POST /flowcharts/generations`. 필요한 범위: `figures:generate`.

| 필드 | 유형 | 필수 | 기본값 | 규칙 |
| --- | --- | --- | --- | --- |
| prompt | string | 예 | — | 1–8,000자 |
| aspect_ratio | string | 아니요 | `auto` | `auto`, `16:9`, `1:1`, `2:3`, `3:2`, `3:4`, `4:3`, `4:5`, `5:4`, `9:16`, `21:9` |
| attachment_file_ids | array | 아니요 | — | 용도 `flowchart_attachment`로 업로드한 파일 최대 8개(예: 실험 절차 또는 초안) |

100 크레딧입니다. 성공한 작업은 편집 가능한 텍스트를 포함한 SVG 결과 하나와 웹사이트 FlowChart 대화에서 여는 `editor_url`을 제공합니다. 무료 [변환](/ko/docs/api/image-conversions)으로 PNG, PDF, TIFF 또는 PPTX를 내보내세요.

첨부 파일은 먼저 `POST /files` 및 용도 `flowchart_attachment`로 업로드합니다. 웹사이트 업로드 한도에 집계되며 24시간 동안 사용할 수 있습니다.

## 편집

JSON `{"job": "<flowchart job id>", "instruction": "..."}`을 포함한 `POST /flowcharts/edits`는 해당 작업의 순서도를 화면 비율을 유지하며 수정합니다. `instruction`은 1–8,000자이며, 100 크레딧입니다. [그래프 편집](/ko/docs/api/charts)과 같은 규칙이 적용됩니다. 상위 작업이 실행 중이면 재시도 가능한 `409 REVISION_CONFLICT`(`PARENT_JOB_RUNNING`), 실패했다면 `400 INVALID_REQUEST`(`JOB_NOT_SUCCEEDED`)를 반환합니다. 최신 버전만 편집할 수 있고(`409 REVISION_CONFLICT`, `NOT_LATEST_REVISION`), 편집은 한 번에 하나만 실행되며(`EDIT_IN_PROGRESS`), 결과는 웹사이트의 동일한 FlowChart 대화에 표시됩니다.

## cURL

```bash
curl -X POST https://scifig.ai/api/v1/flowcharts/generations \
  -H "Authorization: Bearer $SCIFIG_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Prefer: wait=25" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "CONSORT flow of a randomized trial: 400 assessed, 80 excluded, 320 randomized into two arms of 160, follow-up and analysis",
    "aspect_ratio": "4:3"
  }'
```

## JavaScript

```javascript
const response = await fetch('https://scifig.ai/api/v1/flowcharts/generations', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.SCIFIG_API_KEY}`,
    'Idempotency-Key': crypto.randomUUID(),
    Prefer: 'wait=25',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "prompt": "CONSORT flow of a randomized trial: 400 assessed, 80 excluded, 320 randomized into two arms of 160, follow-up and analysis",
    "aspect_ratio": "4:3"
  }),
});
const result = await response.json();
console.log(response.status, result);
```

## Python

```python
import os
import uuid

import requests

headers = {
    "Authorization": f"Bearer {os.environ['SCIFIG_API_KEY']}",
    "Idempotency-Key": str(uuid.uuid4()),
    "Prefer": "wait=25",
}
response = requests.post(
    "https://scifig.ai/api/v1/flowcharts/generations",
    headers=headers,
    json={
        "prompt": "CONSORT flow of a randomized trial: 400 assessed, 80 excluded, 320 randomized into two arms of 160, follow-up and analysis",
        "aspect_ratio": "4:3"
    },
    timeout=60,
)
print(response.status_code, response.json())
```
