Vectorizer.AI offers a full-fledged bitmap tracing API. The API traces pixels to vectors fully automatically and with best-in-class fidelity.
POST a bitmap image and get a vectorized result back:
$ curl https://vectorizer.ai/api/v1/vectorize \ -u xyz123:[secret] \ -F image=@example.jpeg \ -o result.svg
// Requires: org.apache.httpcomponents.client5:httpclient5-fluent Request request = Request.post("https://vectorizer.ai/api/v1/vectorize") .addHeader("Authorization", "Basic dmt5YzY3a3FhMjd5aWRkOltzZWNyZXRd") .body( MultipartEntityBuilder.create() .addBinaryBody("image", new File("example.jpeg")) // TODO: Replace with your image // TODO: Add more upload parameters here .build() ); ClassicHttpResponse response = (ClassicHttpResponse) request.execute().returnResponse(); if (response.getCode() == 200) { // Write result to disk, TODO: or wherever you'd like try (FileOutputStream out = new FileOutputStream("result.svg")) { response.getEntity().writeTo(out); } } else { System.out.println("Request Failed: Status: " + response.getCode() + ", Reason: " + response.getReasonPhrase()); }
using (var client = new HttpClient()) using (var form = new MultipartFormDataContent()) { client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", "INSERT_API_KEY_HERE"); form.Add(new ByteArrayContent(File.ReadAllBytes("example.jpeg")), "image", "example.jpeg"); // TODO: Replace with your image // TODO: Add more upload parameters here var response = client.PostAsync("https://vectorizer.ai/api/v1/vectorize", form).Result; if (response.IsSuccessStatusCode) { // Write result to disk, TODO: or wherever you'd like FileStream outStream = new FileStream("result.svg", FileMode.Create, FileAccess.Write, FileShare.None); response.Content.CopyToAsync(outStream).ContinueWith((copyTask) => { outStream.Close(); }); } else { Console.WriteLine("Request Failed: Status: " + response.StatusCode + ", Reason: " + response.ReasonPhrase); } }
// Requires "request" to be installed (see https://www.npmjs.com/package/request) var request = require('request'); var fs = require('fs'); request.post({ url: 'https://vectorizer.ai/api/v1/vectorize', formData: { image: fs.createReadStream('example.jpeg'), // TODO: Replace with your image // TODO: Add more upload options here }, auth: {user: 'xyz123', pass: '[secret]'}, followAllRedirects: true, encoding: null }, function(error, response, body) { if (error) { console.error('Request failed:', error); } else if (!response || response.statusCode != 200) { console.error('Error:', response && response.statusCode, body.toString('utf8')); } else { // Save result fs.writeFileSync("result.svg", body); } });
$ch = curl_init('https://vectorizer.ai/api/v1/vectorize'); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Basic dmt5YzY3a3FhMjd5aWRkOltzZWNyZXRd')); curl_setopt($ch, CURLOPT_POSTFIELDS, array( 'image' => curl_file_create('example.jpeg'), // TODO: Add more upload options here )); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); $data = curl_exec($ch); if (curl_getinfo($ch, CURLINFO_HTTP_CODE) == 200) { // Save result file_put_contents("result.svg", $data); } else { echo "Error: " . $data; } curl_close($ch);
# Either use the sample code below, or this SDK: https://pypi.org/project/vectorizer-ai/ # Requires "requests" to be installed (see https://pypi.org/project/requests/) import requests response = requests.post( 'https://vectorizer.ai/api/v1/vectorize', files={'image': open('example.jpeg', 'rb')}, data={ # TODO: Add more upload options here }, auth=('xyz123', '[secret]') ) if response.status_code == requests.codes.ok: # Save result with open('result.svg', 'wb') as out: out.write(response.content) else: print("Error:", response.status_code, response.text)
# Requires: gem install httpclient require 'httpclient' client = HTTPClient.new default_header: { "Authorization" => "Basic dmt5YzY3a3FhMjd5aWRkOltzZWNyZXRd" } response = client.post("https://vectorizer.ai/api/v1/vectorize", { "image" => File.open("example.jpeg", "rb"), # TODO: Replace with your image # TODO: Add more upload parameters here }) if response.status == 200 then # Write result to disk, TODO: or wherever you'd like File.open("result.svg", 'w') { |file| file.write(response.body) } else puts "Error: Code: " + response.status.to_s + ", Reason: " + response.reason end
$ curl https://vectorizer.ai/api/v1/vectorize \ -u xyz123:[secret] \ -F 'image.url=https://example.com/example.jpeg' \ -o result.svg
// Requires: org.apache.httpcomponents.client5:httpclient5-fluent Request request = Request.post("https://vectorizer.ai/api/v1/vectorize") .addHeader("Authorization", "Basic dmt5YzY3a3FhMjd5aWRkOltzZWNyZXRd") .body( MultipartEntityBuilder.create() .addTextBody("image.url", "https://example.com/example.jpeg") // TODO: Replace with your image URL // TODO: Add more upload parameters here .build() ); ClassicHttpResponse response = (ClassicHttpResponse) request.execute().returnResponse(); if (response.getCode() == 200) { // Write result to disk, TODO: or wherever you'd like try (FileOutputStream out = new FileOutputStream("result.svg")) { response.getEntity().writeTo(out); } } else { System.out.println("Request Failed: Status: " + response.getCode() + ", Reason: " + response.getReasonPhrase()); }
using (var client = new HttpClient()) using (var form = new MultipartFormDataContent()) { client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", "INSERT_API_KEY_HERE"); form.Add(new StringContent("https://example.com/example.jpeg"), "image.url"); // TODO: Replace with your image URL // TODO: Add more upload parameters here var response = client.PostAsync("https://vectorizer.ai/api/v1/vectorize", form).Result; if (response.IsSuccessStatusCode) { // Write result to disk, TODO: or wherever you'd like FileStream outStream = new FileStream("result.svg", FileMode.Create, FileAccess.Write, FileShare.None); response.Content.CopyToAsync(outStream).ContinueWith((copyTask) => { outStream.Close(); }); } else { Console.WriteLine("Request Failed: Status: " + response.StatusCode + ", Reason: " + response.ReasonPhrase); } }
// Requires "request" to be installed (see https://www.npmjs.com/package/request) var request = require('request'); var fs = require('fs'); request.post({ url: 'https://vectorizer.ai/api/v1/vectorize', formData: { 'image.url': 'https://example.com/example.jpeg', // TODO: Replace with your image // TODO: Add more upload options here }, auth: {user: 'xyz123', pass: '[secret]'}, followAllRedirects: true, encoding: null }, function(error, response, body) { if (error) { console.error('Request failed:', error); } else if (!response || response.statusCode != 200) { console.error('Error:', response && response.statusCode, body.toString('utf8')); } else { // Save result fs.writeFileSync("result.svg", body); } });
$ch = curl_init('https://vectorizer.ai/api/v1/vectorize'); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Basic dmt5YzY3a3FhMjd5aWRkOltzZWNyZXRd')); curl_setopt($ch, CURLOPT_POSTFIELDS, array( 'image.url' => 'https://example.com/example.jpeg', // TODO: Add more upload options here )); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); $data = curl_exec($ch); if (curl_getinfo($ch, CURLINFO_HTTP_CODE) == 200) { // Save result file_put_contents("result.svg", $data); } else { echo "Error: " . $data; } curl_close($ch);
# Either use the sample code below, or this SDK: https://pypi.org/project/vectorizer-ai/ # Requires "requests" to be installed (see https://pypi.org/project/requests/) import requests response = requests.post( 'https://vectorizer.ai/api/v1/vectorize', data={ 'image.url': 'https://example.com/example.jpeg', # TODO: Add more upload options here }, auth=('xyz123', '[secret]') ) if response.status_code == requests.codes.ok: # Save result with open('result.svg', 'wb') as out: out.write(response.content) else: print("Error:", response.status_code, response.text)
# Requires: gem install httpclient require 'httpclient' client = HTTPClient.new default_header: { "Authorization" => "Basic dmt5YzY3a3FhMjd5aWRkOltzZWNyZXRd" } response = client.post("https://vectorizer.ai/api/v1/vectorize", { "image.url" => "https://example.com/example.jpeg", # TODO: Replace with your image URL # TODO: Add more upload parameters here }) if response.status == 200 then # Write result to disk, TODO: or wherever you'd like File.open("result.svg", 'w') { |file| file.write(response.body) } else puts "Error: Code: " + response.status.to_s + ", Reason: " + response.reason end
It is free to integrate with and test out the API, no subscription required.
Just use mode=test
for development. You can assess the result quality using the interactive Web App on the front page.
Production results require a subscription and are 1.00 credit each.
We also offer preview results you can show your end-users before they make a purchase.
Previews are PNG images four times larger than your input, come with a discreet watermark, and cost 0.20 credits each.
Just use mode=preview
to get a preview result.
Please see the pricing page for the subscription plans.
The API uses standard HTTP basic access authentication. All requests to the API must be made over HTTPS and include your API Credentials, with the API Id as the user and API Secret as the password.
Your http client library must support Server Name Indication (SNI) to successfully make requests. If you're getting weird handshake errors, this is most likely it.
Usage of the API is rate limited with generous allowances and no hard upper bound.
During normal end-user-driven operation you are unlikely to run into any rate limiting as usage then tends to ebb and flow in a way that the service handles gracefully.
However, for batch jobs we recommend starting out with at most 5 threads, adding 1 new thread every 5 minutes until you have reached the desired level of parallelism. Please reach out before starting if you need more than 100 concurrent threads.
If you submit too many requests you will start getting 429 Too Many Requests
responses. When this happens you should apply linear back off: on the first such response, wait 5 seconds until submitting the next request. On the second consecutive 429 response, wait 2*5=10 seconds until submitting the next request. On the third wait 3*5=15 seconds, etc.
You can reset the back off counter after a successful request, and you should apply the back off on a per-thread basis (i.e. the threads should operate independently of each other).
While API requests are normally completed within seconds, it is possible during transient load spikes to experience longer processing times.
To ensure your client library doesn't prematurely terminate API requests it should be configured with an idle timeout of at least 180 seconds.
We use conventional HTTP statuses to indicate success or failure of an API request, and include important error information in the returned Error JSON Object.
We strive to always return an Error JSON Object with any problematic request. However, it is always theoretically possible to have internal server failures that lead to a non-JSON error response.
Attributes |
|
---|---|
status | The HTTP status of the response, repeated here to help with debugging. |
code | Vectorizer.AI internal error code. |
message | Human-readable error message, intended to be helpful in debugging. |
If the HTTP status for your request is 200 then no Error JSON Object will be returned, and you can safely assume that the request broadly speaking succeeded.
Some HTTP Client libraries raise exceptions for HTTP statuses in the 400
-599
range. You will need to catch those exceptions and handle them appropriately.
HTTP Status | Meaning |
---|---|
200 -299
|
Success |
400 -499
|
There's a problem with the information provided in the request (e.g. a parameter was missing). Please review the error message to figure out how to fix it. |
500 -599
|
There's been a Vectorizer.AI internal error. Wait a moment then try again, and if the problem persists please email us. |
Example Error Response
{ "error" : { "status" : 400, "code" : 1006, "message" : "Failed to read the supplied image. " } }
Recent API errors are listed on your account page for your debugging convenience.
There's also a list of all error responses returned by the API.
POST
https://api.vectorizer.ai/api/v1/vectorize
To vectorize an image, you do a standard HTTP POST file upload. Keep in mind that the Content-Type has to be multipart/form-data
when uploading binary files.
The table below lays out all the API parameters in a working try-it-now form. Each parameter has a brief description, but be sure to check out the detailed Output Options Documentation.
GET
https://api.vectorizer.ai/api/v1/account
Fetch basic information about your account, such as your subscription status and number of credits left.
Parameters |
|
---|---|
None |
Response Attributes |
|
---|---|
subscriptionPlan |
The subscription plan you're currently subscribed to, or 'none'. |
subscriptionState |
The state of your current subscription ('active' or 'pastDue') or 'ended' if not subscribed. |
credits |
The number of API credits left in your account. 0 if not currently subscribed, or subscribed to a non-API plan. Can be fractional, so be sure to parse as a Double. |
Try it out
Username = API Id, Password = API Secret
cURL
$ curl "https://api.vectorizer.ai/api/v1/account" \ -u 123:[secret]
Example Response
{ "subscriptionPlan" : "none", "subscriptionState" : "ended", "credits" : 0 }
Date | Change |
---|---|
Jun 11, 2024 |
Added processing.palette
|
Mar 4, 2024 | Added section about timeouts. |
Jan 24, 2024 | Added the Account Status endpoint. Added recent API errors to the Account page. Added listing of all API error responses. |
Jan 16, 2024 | Documented the Error JSON Object. |
Oct 3, 2023 |
Clarified that output.gap_filler.enabled=true leads to more colors in the result than requested in processing.max_colors .
|
Sep 20, 2023 |
Added mode
|
Aug 1, 2023 |
Added a full-featured output size options group with the following options: output.size.scale , output.size.width , output.size.height , output.size.unit , output.size.aspect_ratio , output.size.align_x , output.size.align_y , output.size.input_dpi , and output.size.output_dpi . Added a bitmap output options group with one option: output.bitmap.anti_aliasing_mode .
|
Jun 7, 2023 |
Added processing.max_colors
|
May 31, 2023 | Greatly expanded the API parameters. Updated the API endpoint. |
Mar 10, 2023 | Initial release. |