Overview
This guide walks you through creating a dataset and populating it with images using the Orq API. You’ll learn how to:- Initialize the Orq client
- Create a new dataset
- Convert images to base64 format
- Add images with prompts to your dataset
Prerequisites
- An Orq API key (to create a new key, see API keys)
- Images in a supported format (JPEG, PNG, GIF, WEBP)
Installation
1
Install the SDK
2
Initialize the Client
3
Create a Dataset
Start by creating a new Dataset to organize your images, we’ll be using the Create Dataset Endpoint.Response:
4
Convert Images to Base64
Images must be encoded as base64 data URLs before adding to the dataset:
5
Add your images to the Dataset
We’ll be using the add Datapoint to a Dataset endpoint.
See the Full Example
View the Full Code
View the Full Code
Here’s a complete working example with error handling:
Image Format Details
Supported Formats
| Format | MIME Type | Extension |
|---|---|---|
| JPEG | image/jpeg | .jpg, .jpeg |
| PNG | image/png | .png |
| GIF | image/gif | .gif |
| WebP | image/webp | .webp |
Detail Parameter
Thedetail parameter controls how the image is processed:
auto(recommended): Automatically optimizes based on image sizelow: Faster processing, lower token usagehigh: More detailed analysis, higher token usage
Error Handling
Common issues and solutions:| Error | Cause | Solution |
|---|---|---|
| Invalid API key | Authentication failed | Check your API key in console.orq.ai/settings/api-keys |
| File not found | Image path is incorrect | Verify the image path and file permissions |
| Unsupported format | Image format not supported | Convert to JPEG, PNG, GIF, or WebP |
| Payload too large | Image file is too large | Compress or resize images before upload |