Skip to content

Getting Started

API Token

If you don’t already have an account navigate to the app.prodia.com and click Sign Up.

Go to the API Dashboard to generate a token. You should see a token management screen similar to this:

Prodia API Dashboard v2 Token Management

If the token management interface isn’t showing up please check that you have an active Pro+ subscription.

Give the token a meaningful label like getting started and click Create API Key:

Prodia API Dashboard v2 Token Create API Key

Next copy the key to a safe location. We will use this key for the remainder of the tutorial.

Prodia API Dashboard v2 Token Copy API Key

Now that we have an API key were are ready to setup the project.

Project Setup

Terminal window
# Create a project directory.
mkdir prodia-getting-started
cd prodia-getting-started

Install Node (if not already installed):

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

Create project skeleton:

Terminal window
# Requires node --version >= 18
# Initialize the project with npm.
npm init -y
# Install the prodia-js library.
npm install prodia --save
Terminal window
# Export your token so it can be used by the main code.
export PRODIA_TOKEN=your-token-here

Create a main file for your project:

main.js
const { createProdia } = require("prodia/v2");
const prodia = createProdia({
token: process.env.PRODIA_TOKEN // get it from environment
});

You’re now ready to make some API calls!

Text to Image

Add the following to the main file:

main.js
const fs = require("node:fs/promises");
const { createProdia } = require("prodia/v2");
const prodia = createProdia({
token: process.env.PRODIA_TOKEN // get it from environment
});
(async () => {
// run a flux dev generation
const job = await prodia.job({
type: "inference.flux.dev.txt2img.v1",
config: {
prompt: "puppies in a cloud, 4k",
}
});
const image = await job.arrayBuffer();
await fs.writeFile("puppies.jpg", new Uint8Array(image));
})();

Run the main code:

Terminal window
node main.js

Open the output image puppies.jpg:

Terminal window
open puppies.jpg

And you’ll see some cute puppies like these:

Prodia API Dashboard v2 Token Management

Congratulations on finishing your first project using Prodia!