{"record":{"id":"f66e7411d0ffb9f3","repo":"Significant-Gravitas/AutoGPT","slug":"missing-replicate-api-key-in-settings","errorCode":null,"errorMessage":"Missing Replicate API key in settings","messagePattern":"Missing Replicate API key in settings","errorType":"exception","errorClass":"ValueError","httpStatus":400,"severity":"error","filePath":"autogpt_platform/backend/backend/api/features/store/image_gen.py","lineNumber":118,"sourceCode":"        credentials=ideogram_credentials,\n    )\n    response = await Requests().get(url)\n    return io.BytesIO(response.content)\n\n\nasync def generate_agent_image_v1(agent: GraphBaseMeta | AgentGraph) -> io.BytesIO:\n    \"\"\"\n    Generate an image for an agent using Flux model via Replicate API.\n\n    Args:\n        agent (GraphBaseMeta | AgentGraph): The agent to generate an image for\n\n    Returns:\n        io.BytesIO: The generated image as bytes\n    \"\"\"\n    try:\n        if not settings.secrets.replicate_api_key:\n            raise ValueError(\"Missing Replicate API key in settings\")\n\n        # Construct prompt from agent details\n        prompt = (\n            \"Create a visually engaging app store thumbnail for the AI agent \"\n            \"that highlights what it does in a clear and captivating way:\\n\"\n            f\"- **Name**: {agent.name}\\n\"\n            f\"- **Description**: {agent.description}\\n\"\n            f\"Focus on showcasing its core functionality with an appealing design.\"\n        )\n\n        # Set up Replicate client\n        client = ReplicateClient(api_token=settings.secrets.replicate_api_key)\n\n        # Model parameters\n        input_data = {\n            \"prompt\": prompt,\n            \"width\": 1024,\n            \"height\": 768,","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/features/store/image_gen.py#L100-L136","documentation":"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.","triggerScenarios":"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.","commonSituations":"Fresh local setup without completing .env; staging/prod secret rotation that removed the key; a new deployment profile that omits the Replicate secret.","solutions":["Add REPLICATE_API_KEY to backend/.env (or the deployment's secret store) and restart the backend.","Verify with `poetry run python -c \"from backend.util.settings import Settings; print(bool(Settings().secrets.replicate_api_key))\"`.","If Replicate is intentionally unused, ensure the v2/Ideogram path is enabled and its key is set instead."],"exampleFix":"// before\n# backend/.env\n# REPLICATE_API_KEY=\n\n// after\nREPLICATE_API_KEY=r8_xxxxxxxxxxxxxxxxxxxxxxxx","handlingStrategy":"validation","validationCode":"from backend.util.settings import Settings\n\ndef replicate_ready() -> bool:\n    return bool(Settings().secrets.replicate_api_key)","typeGuard":null,"tryCatchPattern":"try:\n    image = await store_image_gen.generate_agent_image_v1(agent=agent)\nexcept ValueError as e:\n    if \"Replicate API key\" in str(e):\n        raise HTTPException(503, \"Image generation is not configured\") from e\n    raise","preventionTips":["Set required secrets before enabling store image endpoints in an environment.","Surface a config checklist for new deployments instead of failing at request time."],"tags":["store","config","api-key","replicate","image-generation"],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}