If you searched for HeyGen StreamingAvatarAPI NewSessionRequest background type color value hex, you probably have the HeyGen docs open in one tab and a broken API call in the other. This guide gives you the straight answer: which HeyGen API endpoints accept the background parameter, which ones ignore it, and exactly how to get a custom background color on a streaming avatar session.
All code examples below are verified against HeyGen's v2 API documentation and the LiveAvatar Web SDK as of May 2026.
The Background Parameter: Where It Works
HeyGen has two fundamentally different APIs for avatar video:
| API | Background Parameter | Status (May 2026) |
|---|---|---|
Studio Video API (/v2/video/generate) |
background.type + background.value |
Works — color, image, video, transparent |
Streaming Avatar (@heygen/streaming-avatar) |
background in createStartAvatar() |
Sunset March 31, 2026 — parameter never worked |
LiveAvatar (@heygen/liveavatar-web-sdk) |
No server-side background param | Active — use client-side chroma-key |
The confusion happens because the Studio Video API and the Streaming Avatar API share similar parameter shapes, but the background object only works in the Studio Video API. HeyGen's own team confirmed this in their developer forums: “The background color of the interactive avatar cannot be customized using the provided parameter. You’ll need to handle the background removal on your side.”
Studio Video API: Working Code (Color, Image, Transparent)
If you are generating pre-rendered avatar videos (not real-time streaming), this is the API you want. The background object goes inside each element of video_inputs.
Solid Color Background (Hex)
cURLcurl -X POST https://api.heygen.com/v2/video/generate \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"video_inputs": [{
"character": {
"type": "avatar",
"avatar_id": "YOUR_AVATAR_ID",
"avatar_style": "normal"
},
"voice": {
"type": "text",
"input_text": "Hello from a custom background.",
"voice_id": "YOUR_VOICE_ID"
},
"background": {
"type": "color",
"value": "#FAFAFA"
}
}],
"dimension": { "width": 1920, "height": 1080 }
}'
Python (requests)
Pythonimport requests
url = "https://api.heygen.com/v2/video/generate"
headers = {
"X-Api-Key": "YOUR_API_KEY",
"Content-Type": "application/json"
}
payload = {
"video_inputs": [{
"character": {
"type": "avatar",
"avatar_id": "YOUR_AVATAR_ID",
"avatar_style": "normal"
},
"voice": {
"type": "text",
"input_text": "Hello from a custom background.",
"voice_id": "YOUR_VOICE_ID"
},
"background": {
"type": "color",
"value": "#1a1a2e" # dark navy
}
}],
"dimension": {"width": 1920, "height": 1080}
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
Other Background Types
The Studio Video API supports four background types:
| Type | Value | Notes |
|---|---|---|
"color" |
Hex code, e.g. "#FAFAFA" |
Any valid 6-digit hex. Include the # prefix. |
"image" |
Public URL or image_asset_id |
HeyGen downloads the image at render time. Must be publicly accessible. |
"video" |
video_asset_id + play_style |
Play styles: loop, freeze, fit_to_scene, full_video |
"transparent" |
None (omit value) |
Output is WebM, not MP4. Larger file sizes. |
Build with HeyGen's API
HeyGen's API uses pay-as-you-go credits starting at $5 minimum. Free plan includes 3 videos/month to test your integration before going live.
Try HeyGen Free → Read Full ReviewStreaming Avatar API: Why Background Does Not Work
The old @heygen/streaming-avatar SDK (v1.x–2.x) accepted a background field in createStartAvatar(). Developers tried passing it like this:
// THIS DOES NOT WORK - shown for reference only
const sessionData = await avatar.createStartAvatar({
quality: AvatarQuality.High,
avatarName: "YOUR_AVATAR_ID",
voice: { voiceId: "YOUR_VOICE_ID" },
background: {
type: "color", // ignored by the API
value: "#000000" // ignored by the API
}
});
The API either silently ignores the background field or returns an error, depending on the SDK version. The streaming session always renders the avatar on a green screen regardless of what you pass.
@heygen/streaming-avatar npm package and the Interactive Avatar API were sunset on March 31, 2026. HeyGen has replaced them with LiveAvatar and the @heygen/liveavatar-web-sdk package. If you are starting a new integration, use LiveAvatar.
LiveAvatar: Client-Side Chroma-Key Workaround
Since neither the old Streaming Avatar API nor the new LiveAvatar API supports server-side background customization, you handle it on the client. The approach: receive the green-screen video stream, remove the green pixels using canvas compositing, then composite your desired background underneath.
HeyGen provides an official reference implementation in their liveavatar-web-sdk repository. The apps/bg-removal-demo app demonstrates:
- Client-side chroma-key on the green-screen video stream
- Swap background to any hex color, image URL, or video URL
- No session restart required when changing backgrounds
How It Works (Simplified)
JavaScript// 1. Capture each video frame onto a hidden canvas
const ctx = canvas.getContext("2d");
ctx.drawImage(videoElement, 0, 0, canvas.width, canvas.height);
// 2. Read pixel data
const frame = ctx.getImageData(0, 0, canvas.width, canvas.height);
const data = frame.data;
// 3. Replace green pixels with transparent
for (let i = 0; i < data.length; i += 4) {
const r = data[i], g = data[i + 1], b = data[i + 2];
// Check if pixel is "green screen" green
if (g > 80 && r < 100 && b < 100) {
data[i + 3] = 0; // set alpha to 0 (transparent)
}
}
// 4. Put modified frame back
ctx.putImageData(frame, 0, 0);
// 5. Composite over your desired background
// (render your background color/image on a layer behind the canvas)
For production use, consider a WebGL shader instead of per-pixel canvas manipulation — it offloads the work to the GPU and handles edge anti-aliasing more gracefully. The HeyGen bg-removal-demo app uses this approach.
To run the official demo locally:
Terminalgit clone https://github.com/heygen-com/liveavatar-web-sdk.git
cd liveavatar-web-sdk
pnpm install
pnpm demo:bg-removal # starts on port 3002
Common Hex Color Values for HeyGen Backgrounds
Whether you are using the Studio Video API (where you pass the hex directly) or a chroma-key replacement (where you render the hex on your background layer), these are the most-used values:
| Color | Hex | Use Case |
|---|---|---|
| White | #FFFFFF |
Clean corporate look, training videos |
| Off-White / Light Gray | #FAFAFA |
Softer than pure white, reduces glare on screen |
| Dark Navy | #1a1a2e |
Professional dark mode, SaaS product demos |
| Brand Blue | #155DFC |
Branded backgrounds, CTAs |
| Green Screen | #008000 |
Default streaming avatar output (for post-processing) |
| Black | #000000 |
Cinematic, keynote-style presentations |
| Warm Gray | #F5F5F5 |
Neutral background for e-learning |
The hex format for HeyGen's Studio Video API requires the # prefix followed by six hexadecimal digits (e.g., #FAFAFA). Three-digit shorthand (#FFF) is not documented as supported — always use the full six-digit format.
Start Building with HeyGen
HeyGen offers 200+ avatars and Avatar V — the most realistic AI avatar available in 2026. API credits are pay-as-you-go (from $5). Free plan available for testing.
Try HeyGen Free → See Pricing BreakdownFrequently Asked Questions
Does the HeyGen Streaming Avatar API support custom background colors via NewSessionRequest?
No. As of May 2026, the background parameter with type: "color" and a hex value does NOT work in the Streaming Avatar or LiveAvatar API. The parameter is accepted only in the Studio Video API (/v2/video/generate). Streaming avatars render on a green screen (#008000) by default. You must remove the green screen client-side using chroma-key compositing.
Why does my background parameter return an error in createStartAvatar?
The background object ({ type: "color", value: "#000" }) is a Studio Video API parameter. It does not apply to the Streaming Avatar SDK (createStartAvatar) or the LiveAvatar Web SDK. HeyGen's team confirmed this in their developer forums. The streaming session always outputs a green-screen feed regardless of what you pass in the background field.
How do I get a transparent or custom background in HeyGen LiveAvatar?
Use client-side chroma-key removal. HeyGen's official liveavatar-web-sdk repository includes a bg-removal-demo app that performs canvas-based green-screen removal on the video stream. It lets you swap the background to any color, image, or video URL without restarting the session.
What hex color is the HeyGen streaming avatar green screen?
The approximate hex value is #008000. Your chroma-key implementation should target this hue range. The exact shade may vary slightly between avatar models, so use a tolerance threshold (e.g., HSL hue 100–140, saturation > 40%) rather than an exact pixel match.
What happened to the HeyGen Interactive Avatar API?
HeyGen's Interactive Avatar API (the @heygen/streaming-avatar npm package) was sunset on March 31, 2026. It has been replaced by the LiveAvatar API with the @heygen/liveavatar-web-sdk package. All new integrations should use LiveAvatar. The LiveAvatar API uses credits at 1–2 credits/minute depending on mode (LITE vs FULL).
Related Guides
- HeyGen Review 2026: 30+ Features Tested — full platform review including Avatar V, Interactive Avatars, and API features
- Best AI Talking Head Tools 2026 — how HeyGen compares to Synthesia, D-ID, and others for avatar video
- HeyGen Pricing 2026: Plans & Cost Per Minute — API credit costs, plan breakdowns, and per-minute economics
- Best AI Video Tools 2026 (Top 10 Ranked) — the definitive ranking of all AI video platforms
Last updated: May 21, 2026. Pricing and API behavior verified against HeyGen documentation and developer forum responses.