Getting started overview

This guide outlines the process for new users to configure and execute their initial API request with ObjectCut. ObjectCut is an API-first service designed for automated image manipulation tasks, such as removing backgrounds, upscaling images, and segmenting objects. The primary steps involve setting up an account, generating an API key, and then using this key to authenticate requests to the ObjectCut API. The API supports various image formats and offers endpoints tailored for specific image processing functions.

ObjectCut provides client libraries (SDKs) for several programming languages, including Python, Node.js, PHP, Java, and Ruby, to simplify integration. These SDKs abstract the underlying HTTP requests, allowing developers to interact with the API using native language constructs. For direct HTTP requests, the API typically uses RESTful principles, accepting JSON payloads and returning processed image data or URLs to hosted results. Authentication is primarily handled via API keys passed in request headers.

Developers targeting a variety of applications, from e-commerce platforms requiring bulk image processing to mobile apps needing on-the-fly image adjustments, can integrate ObjectCut. Understanding the API's rate limits and credit system, detailed on the ObjectCut pricing page, is important for managing usage and costs. The free tier allows for 50 API calls per month, suitable for initial testing and development.

The following sections will guide you through each step, from account creation to successfully making your first API call, specifically focusing on the background removal functionality as a common starting point. This process is designed to be straightforward, enabling quick integration into existing or new projects.

Create an account and get keys

To begin using ObjectCut, you must first create an account and obtain an API key. This key authenticates your requests and links them to your usage plan.

  1. Navigate to the ObjectCut Website: Open your web browser and go to the ObjectCut homepage.
  2. Sign Up: Locate the "Sign Up" or "Get Started Free" button, typically found in the top right corner or prominent on the landing page. Click it to initiate the account creation process.
  3. Provide Account Details: You will be prompted to enter an email address and create a password. Some services may also request your name or company information during this step. Ensure you use a valid email address as it may be used for verification.
  4. Verify Your Email (if required): ObjectCut may send a verification email to the address you provided. Follow the instructions in the email to confirm your account. This is a common security measure to ensure account ownership, as described in general email verification best practices by Google Developers on email/password authentication.
  5. Log In: Once your account is created and verified, log in using your newly established credentials.
  6. Access Your Dashboard: Upon successful login, you will be directed to your personal ObjectCut dashboard. This dashboard is the central hub for managing your account, viewing usage statistics, and accessing API keys.
  7. Locate API Keys: Within the dashboard, look for a section labeled "API Keys," "Developers," or "Settings." The exact naming may vary, but it will contain an option to generate or view your API keys. Click on this section.
  8. Generate/Copy API Key: If no key exists, you may need to click a button like "Generate New API Key." If a key is already present, copy it. This key is a unique string of characters essential for authenticating your API calls. Treat your API key like a password; do not expose it in client-side code or public repositories.
  9. Store Your API Key Securely: Copy the generated API key and store it in a secure location. For development, you might store it in environment variables (e.g., .env files) or a secrets manager, rather than hardcoding it directly into your application code. This practice protects your credentials and prevents unauthorized access to your account.

With your API key in hand, you are ready to proceed to making your first request.

Your first request

This section demonstrates how to make a basic API call to ObjectCut, specifically targeting the background removal functionality, using both a direct HTTP request (via cURL) and a Python SDK example. Ensure you have your API key from the previous step.

Using cURL (Direct HTTP Request)

cURL is a command-line tool and library for transferring data with URLs, commonly used for testing API endpoints. This example sends an image to the background removal endpoint.

Prerequisites:

  • A sample image file (e.g., input.jpg) with an object whose background you wish to remove.
  • Your ObjectCut API key.

cURL Command:

curl -X POST \ 
  'https://api.objectcut.com/v1/remove-background' \ 
  -H 'X-Api-Key: YOUR_OBJECTCUT_API_KEY' \ 
  -F 'image_file=@/path/to/your/input.jpg' \ 
  -o 'output.png'

Explanation:

  • -X POST: Specifies the HTTP POST method.
  • 'https://api.objectcut.com/v1/remove-background': The specific API endpoint for background removal. Refer to the ObjectCut API reference for other available endpoints like image upscaling or object detection.
  • -H 'X-Api-Key: YOUR_OBJECTCUT_API_KEY': Sets the X-Api-Key HTTP header, which is where your ObjectCut API key must be placed for authentication. Replace YOUR_OBJECTCUT_API_KEY with your actual key.
  • -F 'image_file=@/path/to/your/input.jpg': Specifies the image file to be uploaded. The @ symbol tells cURL to read the file from the specified path. Replace /path/to/your/input.jpg with the actual path to your image file.
  • -o 'output.png': Saves the API response (the processed image) to a file named output.png in the current directory.

After executing this command, a file named output.png should appear in your directory, containing your image with the background removed.

Using the Python SDK

Using an SDK often simplifies API interactions by handling HTTP requests, authentication, and data serialization/deserialization. ObjectCut provides an official Python SDK.

Prerequisites:

  • Python installed (version 3.6 or higher recommended).
  • The ObjectCut Python SDK installed.
  • A sample image file (e.g., input.jpg).
  • Your ObjectCut API key.

Installation:

pip install objectcut-python

Python Code Example:

import objectcut

# Configure the SDK with your API key
objectcut.api_key = "YOUR_OBJECTCUT_API_KEY"

def remove_background_with_sdk(image_path, output_path):
    try:
        with open(image_path, 'rb') as image_file:
            # Call the background removal endpoint
            result = objectcut.Image.remove_background(
                image_file=image_file,
                # Optional: specify desired output format, e.g., 'png', 'jpg'
                output_format='png'
            )

            # Save the result
            with open(output_path, 'wb') as out_file:
                out_file.write(result.image_data)
            print(f"Background removed image saved to {output_path}")

    except objectcut.ObjectCutError as e:
        print(f"ObjectCut API Error: {e}")
    except FileNotFoundError:
        print(f"Error: Image file not found at {image_path}")
    except Exception as e:
        print(f"An unexpected error occurred: {e}")

# Replace with your image file path and desired output path
input_image = "./input.jpg"
output_image = "./output_sdk_output.png"

remove_background_with_sdk(input_image, output_image)

Explanation:

  • import objectcut: Imports the ObjectCut Python SDK.
  • objectcut.api_key = "YOUR_OBJECTCUT_API_KEY": Sets your API key globally for the SDK. Replace the placeholder with your actual key.
  • The remove_background_with_sdk function opens the input image, calls objectcut.Image.remove_background(), and then writes the returned image data to an output file.
  • Error handling is included to catch potential API errors or file issues.

This Python example provides a more programmatic way to interact with the ObjectCut API, demonstrating how SDKs streamline development.

Common next steps

After successfully making your first API call, consider these next steps to further integrate ObjectCut into your applications:

  1. Explore Other Endpoints: ObjectCut offers various image processing capabilities beyond background removal. Review the ObjectCut API reference documentation to understand endpoints for image upscaling, object detection, and segmentation. Experiment with these to see how they fit into your workflow.
  2. Implement Error Handling: Production applications require robust error handling. Integrate try-catch blocks (or equivalent in your language) to gracefully manage API errors, network issues, and invalid input. The ObjectCut SDKs typically provide specific exception types for API-related errors.
  3. Manage API Keys Securely: For deployed applications, avoid hardcoding API keys. Use environment variables, a secrets management service (e.g., AWS Secrets Manager, Google Secret Manager), or a configuration management system to store and retrieve keys securely.
  4. Monitor Usage and Billing: Regularly check your ObjectCut dashboard to monitor API call usage against your free tier limits or paid plan. Understand the credit system and how different operations consume credits. This helps manage costs and prevent unexpected interruptions of service. Details are available on the ObjectCut pricing page.
  5. Optimize Performance: For applications processing many images, consider strategies like batch processing (if supported by the API or SDK), asynchronous requests, and caching results for frequently accessed images to improve performance and reduce API call volume.
  6. Integrate into Your Application Workflow: Plan how ObjectCut fits into your existing application logic. This might involve integrating it into an image upload pipeline, a content management system, or a workflow automation tool like Tray.io for workflow automation, which often includes connectors for image processing services.
  7. Review Best Practices: Consult the ObjectCut documentation for best practices regarding image input sizes, file formats, and recommended usage patterns to ensure optimal results and efficient resource utilization.
  8. Explore Webhooks (if available): If your application requires real-time notifications about the completion of long-running image processing tasks, check if ObjectCut supports webhooks. Webhooks allow the API to notify your application directly when a process finishes, rather than requiring your application to poll for status updates.

Troubleshooting the first call

Encountering issues during your first API call is common. Here's a guide to diagnose and resolve frequent problems:

Issue What to Check Where to Check
401 Unauthorized / Invalid API Key Is your API key correctly included in the X-Api-Key header? Is there a typo? Your code/cURL command, ObjectCut dashboard (to re-copy key)
400 Bad Request / Invalid Input Is the image file path correct? Is the file accessible? Is the image format supported (e.g., JPEG, PNG)? Is the endpoint URL correct? Your code/cURL command, file system, ObjectCut API reference for supported formats
403 Forbidden / Rate Limit Exceeded Have you exceeded your free tier limits or paid plan limits? ObjectCut dashboard (usage statistics), ObjectCut pricing page
Network Error / Timeout Is your internet connection stable? Are there any firewalls or proxy settings blocking the request? Your network configuration, browser (to test connectivity to api.objectcut.com)
SDK-specific Errors Is the SDK installed correctly? Are you using the correct method names and parameters as per the SDK documentation? Your code, SDK documentation (e.g., ObjectCut Python SDK documentation)
No Output File / Empty Output Is the output path writable? Did the API return an error that prevented image generation? Your file system permissions, API response (check for error messages in cURL or SDK exceptions)
Unexpected JSON Response / Non-Image Data Did the API return an error message in JSON format instead of an image? This often indicates an issue with the request or authentication. Check the full API response body for error details.

General Troubleshooting Steps:

  1. Double-check everything: Carefully review your API key, endpoint URL, image file path, and request headers. A minor typo can cause significant issues.
  2. Consult the ObjectCut Documentation: The official ObjectCut documentation is the primary source for specific error codes, supported parameters, and usage examples.
  3. Inspect API Response: If using cURL, remove the -o 'output.png' part to see the raw API response in your terminal. This can often contain detailed error messages. If using an SDK, print out the full exception or error object.
  4. Test with a known good image: Use a simple, small image file that you know is valid to rule out issues with your specific input image.
  5. Verify internet connectivity: Ensure your machine can reach api.objectcut.com.
  6. Check firewall/proxy: If you are working in a corporate environment, a firewall or proxy might be interfering with outgoing requests. Consult your IT department.
  7. Seek Support: If you've exhausted troubleshooting options, reach out to ObjectCut's support team with details of your API call, error messages, and steps taken.