Image Quickstart
Get started with our Image API
Before we proceed, you need to create an API key.
This key will be used to authenticate your requests to the Topaz Labs API.
Now, proceed with the below steps.
npm install form-datapip install requestsexport TOPAZ_API_KEY="PASTE_YOUR_API_KEY_HERE"export TOPAZ_API_KEY="PASTE_YOUR_API_KEY_HERE"Now you can call the Enhance Generative endpoint:
import fs from 'fs';
import FormData from 'form-data';
const API_KEY = process.env.TOPAZ_API_KEY;
const HEADERS = { 'X-API-KEY': API_KEY };
const IMAGE_BASE = 'https://api.topazlabs.com/image/v1';
// Submit the job
const form = new FormData();
form.append('model', 'Wonder 3.5');
form.append('output_format', 'jpeg');
form.append('image', fs.createReadStream('photo.jpg'));
const response = await fetch(`${IMAGE_BASE}/enhance-gen/async`, {
method: 'POST',
headers: { ...HEADERS, ...form.getHeaders() },
body: form,
});
const { process_id } = await response.json();
// Poll for completion
let status;
do {
await new Promise(resolve => setTimeout(resolve, 2000));
const statusRes = await fetch(`${IMAGE_BASE}/status/${process_id}`, {
headers: HEADERS,
});
({ status } = await statusRes.json());
console.log(`Status: ${status}`);
if (status === 'Failed' || status === 'Cancelled') {
throw new Error(`Job ended with status: ${status}`);
}
} while (status !== 'Completed');
// Download the result
const downloadRes = await fetch(`${IMAGE_BASE}/download/${process_id}`, {
headers: HEADERS,
});
const { download_url } = await downloadRes.json();
console.log(`Download your image: ${download_url}`);Once you find a model that you want to use in our "Models" tab, you can grab the URL from the model's dedicated page. Individual model pages also provide some important information about the model including use cases and examples of how you can call it.
Check out our Model Playground to tinker with these models and let us know your feedback and questions on our Developer Discord.
More Information
Please reach out to help@topazlabs.com with any questions.
Next Steps
Last updated
Was this helpful?
