Significant-Gravitas/AutoGPT · error · ValueError

Missing Replicate API key in settings

Error message

Missing Replicate API key in settings

What it means

ValueError raised at the top of generate_agent_image_v1() when settings.secrets.replicate_api_key is falsy. The v1 generator (Flux via Replicate) treats the key as a precondition and aborts before building the prompt or constructing ReplicateClient.

Source

Thrown at autogpt_platform/backend/backend/api/features/store/image_gen.py:118

        credentials=ideogram_credentials,
    )
    response = await Requests().get(url)
    return io.BytesIO(response.content)


async def generate_agent_image_v1(agent: GraphBaseMeta | AgentGraph) -> io.BytesIO:
    """
    Generate an image for an agent using Flux model via Replicate API.

    Args:
        agent (GraphBaseMeta | AgentGraph): The agent to generate an image for

    Returns:
        io.BytesIO: The generated image as bytes
    """
    try:
        if not settings.secrets.replicate_api_key:
            raise ValueError("Missing Replicate API key in settings")

        # Construct prompt from agent details
        prompt = (
            "Create a visually engaging app store thumbnail for the AI agent "
            "that highlights what it does in a clear and captivating way:\n"
            f"- **Name**: {agent.name}\n"
            f"- **Description**: {agent.description}\n"
            f"Focus on showcasing its core functionality with an appealing design."
        )

        # Set up Replicate client
        client = ReplicateClient(api_token=settings.secrets.replicate_api_key)

        # Model parameters
        input_data = {
            "prompt": prompt,
            "width": 1024,
            "height": 768,

View on GitHub (pinned to 9c8bb5550f)

Solutions

  1. Add REPLICATE_API_KEY to backend/.env (or the deployment's secret store) and restart the backend.
  2. Verify with `poetry run python -c "from backend.util.settings import Settings; print(bool(Settings().secrets.replicate_api_key))"`.
  3. If Replicate is intentionally unused, ensure the v2/Ideogram path is enabled and its key is set instead.

Example fix

// before
# backend/.env
# REPLICATE_API_KEY=

// after
REPLICATE_API_KEY=r8_xxxxxxxxxxxxxxxxxxxxxxxx
Defensive patterns

Strategy: validation

Validate before calling

from backend.util.settings import Settings

def replicate_ready() -> bool:
    return bool(Settings().secrets.replicate_api_key)

Try / catch

try:
    image = await store_image_gen.generate_agent_image_v1(agent=agent)
except ValueError as e:
    if "Replicate API key" in str(e):
        raise HTTPException(503, "Image generation is not configured") from e
    raise

Prevention

When it happens

Trigger: Agent-image generation request on a deployment that selects the v1 path while REPLICATE_API_KEY is unset in backend secrets — missing env var in docker-compose, .env not copied from .env.default plus overrides, or a deployed environment that was never provisioned with the key.

Common situations: Fresh local setup without completing .env; staging/prod secret rotation that removed the key; a new deployment profile that omits the Replicate secret.

Related errors


AI-assisted analysis of Significant-Gravitas/AutoGPT@9c8bb5550f (2026-08-14). Data as JSON: /api/errors/f66e7411d0ffb9f3. Report an issue: GitHub.