> ## Documentation Index
> Fetch the complete documentation index at: https://docs.magichour.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# AI Headshot Generator API

> Generate professional-quality headshots from a single photo.

export const ToolSection = ({type = "image", outputs = [], title = "", productSlug = "", apiSlug = ""}) => <>
    <CardGroup cols={2}>
      <Card title={`${title} API reference`} icon="webhook" horizontal href={`/api-reference/${type}-projects/${apiSlug}`}>
        Request fields, responses, and examples
      </Card>
      <Card title="API quickstart" icon="forward-fast" horizontal href="/get-started/quick-start">
        Install an SDK and complete your first generation
      </Card>
    </CardGroup>

    <p>
      Check <a href="/billing/overview">API pricing</a> and <a href="/api-reference/models">model credit costs</a>, then <a href={`https://magichour.ai/developer?tab=api-keys&ref=docs-tool-${apiSlug}&utm_source=docs&utm_medium=referral&utm_campaign=tools`}>create an API key</a>.
    </p>
    <p>
      To try {title} without code, use the <a href={`https://magichour.ai/products/${productSlug}${productSlug.includes("?") ? "&" : "?"}utm_source=docs&utm_medium=referral&utm_campaign=tools`}>browser tool</a>.
    </p>

    {outputs && outputs.length > 0 && <Tabs>
        {outputs.map((output, idx) => <Tab key={idx} title={`Example Output ${idx + 1}`}>
            <Frame>
              {type === "video" ? <video controls preload="metadata" playsInline className="rounded-lg h-80" src={`${output.src}#t=0.001`} type={`${output.src?.endsWith("mp4") ? 'video/mp4' : "video/webm"}`}>
                </video> : type === "audio" ? <audio controls preload="metadata" className="w-full" src={output.src}>
                  Your browser does not support the audio element.
                </audio> : <img height="320" className="rounded-lg h-80" src={output.src} alt={`${title} example output ${idx + 1}`} />}
            </Frame>
          </Tab>)}
      </Tabs>}

  </>;

## Overview

AI Headshot Generator creates a professional-quality headshot from a single photo while maintaining the person's facial features and identity.

<ToolSection
  title="AI Headshot Generator"
  productSlug="ai-headshot-generator"
  apiSlug="ai-headshot-generator"
  type="image"
  outputs={[
{
  src: "https://d28dkohlqf5vwj.cloudfront.net/ai-headshots/ai-generated/lebron.jpg",
},
{
  src: "https://d28dkohlqf5vwj.cloudfront.net/ai-headshots/ai-generated/zendaya.jpg",
},
]}
/>

## How It Works

1. Upload a clear photo containing exactly one detectable face.
2. **Customize the style** - Optionally specify background, attire, or style preferences
3. **API generates a headshot** - AI creates a professional headshot
4. **Download the result** - Retrieve your professional headshot

## Use Cases

* **LinkedIn profiles** - Create polished professional photos
* **Corporate directories** - Generate consistent employee headshots
* **Resume photos** - Professional images for job applications
* **Acting portfolios** - Multiple headshot variations from one photo
* **Social media profiles** - Professional presence across platforms

## Best Practices

### Source Photo Requirements

<Tip>
  **Use a clear, front-facing photo** - The AI needs to clearly see the person's face for best
  results.
</Tip>

* **Good lighting** - Even, natural lighting works best
* **Front-facing or slight angle** - Avoid extreme profile shots
* **Clear face visibility** - No sunglasses, masks, or heavy shadows
* **Neutral expression** - Natural smile or neutral expression recommended
* Aim for at least 512x512 pixels in the face area.

### Style Customization

Omit `style.prompt` to use the default headshot style, or supply a prompt to customize the output:

**✅ Good prompts:**

* "Professional corporate headshot with neutral gray background"
* "Friendly business casual with soft natural lighting"
* "Executive portrait with dark blue suit"

## Code Examples

### Basic Headshot Generation

<CodeGroup>
  ```python Python theme={null}
  from magic_hour import Client
  import os

  client = Client(token=os.getenv("MAGIC_HOUR_API_KEY"))

  result = client.v1.ai_headshot_generator.generate(
      assets={
          "image_file_path": "https://raw.githubusercontent.com/runshouse/Sample_Assets/main/lebron.jpg"
      },
      style={
          "prompt": "Transform my selfie into a fresh but professional image suitable for Linkedin. The lighting should be natural, flattering, and multidimensional."
      },
      name="Professional Headshot",
      wait_for_completion=True,
      download_outputs=True,
      download_directory="."
  )

  if result.status == "complete":
      print(f"✅ Headshot complete!")
      print(f"Downloaded to: {result.downloaded_paths}")
      print(f"Credits charged: {result.credits_charged}")
  else:
      print(f"❌ Job failed with status: {result.status}")
      if result.error:
          print(f"Error: {result.error.code}: {result.error.message}")
  ```

  ```javascript Node.js theme={null}
  import { Client } from "magic-hour";

  const client = new Client({ token: process.env.MAGIC_HOUR_API_KEY });

  const result = await client.v1.aiHeadshotGenerator.generate(
    {
      assets: {
        imageFilePath: "https://raw.githubusercontent.com/runshouse/Sample_Assets/main/tomcruise.png",
      },
      style: {
        prompt: "Professional corporate headshot with neutral gray background",
      },
      name: "Professional Headshot",
    },
    {
      waitForCompletion: true,
      downloadOutputs: true,
      downloadDirectory: ".",
    }
  );

  console.log(`Status: ${result.status}`);
  console.log(`Downloaded to: ${result.downloadedPaths}`);
  ```
</CodeGroup>

## Pricing

| Output     | Credits    |
| :--------- | :--------- |
| 1 headshot | 50 credits |

<Tip>
  **Try this in our Google Colab Cookbook:** [Run this API with sample
  code](https://colab.research.google.com/drive/1NTHL_lr_s-qBJ-mSecSXPzRLi9_V5JiU?usp=sharing). Just
  add your API key.
</Tip>

## API Reference

<Card title="AI Headshot Generator API Reference" icon="webhook" href="/api-reference/image-projects/ai-headshot-generator">
  View full API specification
</Card>

## Related Tools

<CardGroup cols={2}>
  <Card title="Face Swap Photo" icon="user" href="/tools/image/face-swap-photo">
    Swap faces between photos
  </Card>

  <Card title="AI Clothes Changer" icon="shirt" href="/tools/image/clothes-changer">
    Change outfits in photos
  </Card>
</CardGroup>
