# Generating and Vectorising Logos

Source: https://docs.prodia.com/workflows/generating-and-vectorizing-logos/

This Workflow generates a raster logo with [Flux Schnell](https://docs.prodia.com/models/flux-2/) and converts it to an SVG with Recraft's image-to-vector model. The output is an infinitely scalable vector file ready for a website, app icon, or print asset — all in a single API call.

| Generated raster logo                                                                                                   | Vectorised output                                                                  |
| ----------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
| ![Generated raster paper-airplane logo](https://docs.prodia.com/llms/assets/a63fddb36560-workflow-vectorize-before.jpg) | [Vector paper-airplane logo](https://docs.prodia.com/workflow-vectorize-after.svg) |

### Project Setup

```bash
# Create a project directory.
mkdir prodia-vectorise-workflow
cd prodia-vectorise-workflow
```

### prodia-js

Install Node (if not already installed):

### macOS

```bash
brew install node
# Close the current terminal and open a new one so that node is available.
```

### Linux

```bash
apt install node
# Close the current terminal and open a new one so that node is available.
```

### Windows

```bash
winget install -e --id OpenJS.NodeJS.LTS
# Close the current terminal and open a new one so that node is available.
```

Create project skeleton:

```bash
# Requires node --version >= 18
# Initialize the project with npm.
npm init -y

# Install the prodia-js library.
npm install prodia --save
```

### requests

Install Python (if not already installed):

### macOS

```bash
brew install python
# Close the current terminal and open a new one so that python is available.
```

### Linux

```bash
apt install python3 python3-venv python-is-python3
# Close the current terminal and open a new one so that python is available.
```

### Windows

```bash
winget install -e --id Python.Python.3.12
# Close the current terminal and open a new one so that python is available.
```

```bash
# Requires python --version >= 3.12
python -m venv venv
source venv/bin/activate
pip install requests
```

### curl

Install curl (if not already installed):

### macOS

```bash
brew install curl
# Close the current terminal and open a new one so that curl is available.
```

### Linux

```bash
apt install curl
# Close the current terminal and open a new one so that curl is available.
```

### Windows

```bash
# NOTE: Windows 10 and up have curl installed by default and this can be
# skipped.
winget install -e --id cURL.cURL
# Close the current terminal and open a new one so that curl is available.
```

```bash
# Export your token so it can be used by the main code.
export PRODIA_TOKEN=your-token-here
```

> note:
>
> Your token is exported to an environment variable. If you close or switch your
> shell you'll need to run `export PRODIA_TOKEN=your-token-here` again.

Create a main file for your project:

### prodia-js

```js title="main.js"
const { createProdia } = require("prodia/v2");

const prodia = createProdia({
    token: process.env.PRODIA_TOKEN // get it from environment
});
```

### requests

Create the following `main.py`

```python title="main.py"
from requests.adapters import HTTPAdapter, Retry
import os
import requests
import sys


prodia_token = os.getenv('PRODIA_TOKEN')
prodia_url = 'https://inference.prodia.com/v2/job'

session = requests.Session()
retries = Retry(allowed_methods=None, status_forcelist=Retry.RETRY_AFTER_STATUS_CODES)
session.mount('http://', HTTPAdapter(max_retries=retries))
session.mount('https://', HTTPAdapter(max_retries=retries))
session.headers.update({'Authorization': f"Bearer {prodia_token}"})
```

### curl

```bash title="main.sh"
set -euo pipefail
```

You're now ready to make some API calls!

### Generate then vectorise (in a single workflow)

The first job generates a flat, vector-friendly raster image. The second job receives that raster and converts it into an SVG.

### prodia-js

```javascript title="main.js"
const { createProdia } = require("prodia/v2");
const fs = require("node:fs/promises");

const prodia = createProdia({
  token: process.env.PRODIA_TOKEN,
});

(async () => {
  const job = await prodia.job({
    type: "workflow.serial.v1",
    config: {
      jobs: [
        {
          type: "inference.flux-fast.schnell.txt2img.v2",
          config: {
            prompt: "minimalist flat logo of a paper airplane flying upward, bold geometric shapes, two-tone blue and white, plain solid background, vector-friendly silhouette",
            width: 1024,
            height: 1024,
            seed: 42,
          },
        },
        {
          type: "inference.recraft.img2vec.v1",
        },
      ],
    },
  }, {
    accept: "image/svg+xml",
  });

  const svg = await job.arrayBuffer();
  await fs.writeFile("logo.svg", new Uint8Array(svg));
  // open logo.svg
})();
```

```bash
node main.js
```

### requests

```python title="main.py"
from requests.adapters import HTTPAdapter, Retry
import os
import requests
import sys


prodia_token = os.getenv('PRODIA_TOKEN')
prodia_url = 'https://inference.prodia.com/v2/job'

session = requests.Session()
retries = Retry(allowed_methods=None, status_forcelist=Retry.RETRY_AFTER_STATUS_CODES)
session.mount('http://', HTTPAdapter(max_retries=retries))
session.mount('https://', HTTPAdapter(max_retries=retries))
session.headers.update({'Authorization': f"Bearer {prodia_token}"})

headers = {
    'Accept': 'image/svg+xml',
}

job = {
    'type': 'workflow.serial.v1',
    'config': {
        'jobs': [
            {
                'type': 'inference.flux-fast.schnell.txt2img.v2',
                'config': {
                    'prompt': 'minimalist flat logo of a paper airplane flying upward, bold geometric shapes, two-tone blue and white, plain solid background, vector-friendly silhouette',
                    'width': 1024,
                    'height': 1024,
                    'seed': 42,
                },
            },
            {
                'type': 'inference.recraft.img2vec.v1',
            },
        ],
    },
}

res = session.post(prodia_url, headers=headers, json=job)
print(f"Request ID: {res.headers['x-request-id']}")
print(f"Status: {res.status_code}")

if res.status_code != 200:
    print(res.text)
    sys.exit(1)

with open('logo.svg', 'wb') as f:
    f.write(res.content)
```

```bash
python main.py
```

### curl

```bash title="main.sh"
set -euo pipefail

cat <<EOF > job.json
{
  "type": "workflow.serial.v1",
  "config": {
    "jobs": [
      {
        "type": "inference.flux-fast.schnell.txt2img.v2",
        "config": {
          "prompt": "minimalist flat logo of a paper airplane flying upward, bold geometric shapes, two-tone blue and white, plain solid background, vector-friendly silhouette",
          "width": 1024,
          "height": 1024,
          "seed": 42
        }
      },
      {
        "type": "inference.recraft.img2vec.v1"
      }
    ]
  }
}
EOF

curl -sSf --retry 3 \
  -H "Authorization: Bearer $PRODIA_TOKEN" \
  -H 'Accept: image/svg+xml' \
  -H 'Content-Type: application/json' \
  --data-binary @job.json \
  --output logo.svg \
  https://inference.prodia.com/v2/job
```

```bash
bash main.sh
```

### macOS

```bash
open logo.svg
```

### Linux

```bash
xdg-open logo.svg
```

### Windows

```bash
start logo.svg
```

### Tips

- *Prompt for vector-friendly raster output.* Flat, two- or three-colour designs with sharp silhouettes vectorise well. Photo-realistic or gradient-heavy images will produce SVGs with hundreds of paths and won't look like a logo.
- *Native vector generation.* If you don't need to start from a raster, [Recraft V4](https://docs.prodia.com/models/recraft-v4/) supports `inference.recraft.v4.txt2vec.v1` and `inference.recraft.v4.pro.txt2vec.v1` which generate SVGs directly from a prompt — see [Vectorising Images](https://docs.prodia.com/guides/vectorizing-images/).
