Go + PixelPanda API

Remove Background with Go

Remove image backgrounds from Go with net/http. Zero dependencies, compiles to a single binary.

$ # No dependencies — uses Go stdlib

Go examples — copy and go

Each example is self-contained. Copy the one that matches your use case.

Quick start

Background removal using Go standard library.

package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "io"
    "mime/multipart"
    "net/http"
    "os"
)

const apiKey = "pk_live_your_api_key"

func removeBackground(imagePath string) (string, error) {
    file, err := os.Open(imagePath)
    if err != nil {
        return "", err
    }
    defer file.Close()

    body := &bytes.Buffer{}
    writer := multipart.NewWriter(body)
    part, _ := writer.CreateFormFile("file", imagePath)
    io.Copy(part, file)
    writer.Close()

    req, _ := http.NewRequest("POST",
        "https://pixelpanda.ai/api/v1/remove-background", body)
    req.Header.Set("Authorization", "Bearer "+apiKey)
    req.Header.Set("Content-Type", writer.FormDataContentType())

    resp, err := http.DefaultClient.Do(req)
    if err != nil {
        return "", err
    }
    defer resp.Body.Close()

    var result map[string]interface{}
    json.NewDecoder(resp.Body).Decode(&result)
    return result["image_url"].(string), nil
}

func main() {
    url, err := removeBackground("product.jpg")
    if err != nil {
        fmt.Println("Error:", err)
        return
    }
    fmt.Println("Result:", url)
}

Response format

Every successful request returns this JSON. The image_url is a permanent link to the transparent PNG.

{
    "success": true,
    "image_url": "https://pub-xxx.r2.dev/results/abc123.png",
    "credits_remaining": 199
}
FieldTypeDescription
successbooleantrue if background was removed successfully
image_urlstringURL to the transparent PNG result (permanent, hosted on CDN)
credits_remainingintegerHow many credits are left on your account

Error codes

CodeMeaning
200Success
401Invalid API key
402Out of credits

Common questions

Zero. Uses only Go stdlib. Compiles to a single static binary.
Use goroutines with a semaphore channel to limit concurrency. 10 concurrent goroutines can process 150+ images per minute.
1 credit per image ($0.029). 280 credits/week for $7.99.

Start removing backgrounds with Go

280 credits/week for $7.99. Copy the code above and go.

Get Your API Key