{"record":{"id":"1210a0313b803d23","repo":"microsoft/autogen","slug":"failed-to-fetch-gallery","errorCode":null,"errorMessage":"Failed to fetch gallery","messagePattern":"Failed to fetch gallery","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-studio/frontend/src/components/views/gallery/api.ts","lineNumber":27,"sourceCode":"        headers: this.getHeaders(),\n      }\n    );\n    const data = await response.json();\n    if (!data.status)\n      throw new Error(data.message || \"Failed to fetch galleries\");\n    return data.data;\n  }\n\n  async getGallery(galleryId: number, userId: string): Promise<Gallery> {\n    const response = await fetch(\n      `${this.getBaseUrl()}/gallery/${galleryId}?user_id=${userId}`,\n      {\n        headers: this.getHeaders(),\n      }\n    );\n    const data = await response.json();\n    if (!data.status)\n      throw new Error(data.message || \"Failed to fetch gallery\");\n    return data.data;\n  }\n\n  async createGallery(\n    galleryData: Partial<Gallery>,\n    userId: string\n  ): Promise<Gallery> {\n    const gallery = {\n      ...galleryData,\n      user_id: userId,\n    };\n\n    console.log(\"Creating gallery with data:\", gallery);\n\n    const response = await fetch(`${this.getBaseUrl()}/gallery/`, {\n      method: \"POST\",\n      headers: this.getHeaders(),\n      body: JSON.stringify(gallery),","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-studio/frontend/src/components/views/gallery/api.ts#L9-L45","documentation":"Catch-all raised when the plain-OpenAI embeddings.create call raises; the original exception is preserved as __cause__. Common underlying errors: 401 invalid API key, 429 quota/rate-limit, model name not available to the key's organization, or network issues.","triggerScenarios":"Vector search with embedding_provider='openai' where openai_client.embeddings.create(model=embedding_model, input=query) throws — e.g. openai_api_key not set (so AsyncOpenAI got None), key invalid, model id typo like 'text-embedding-3-sm', or exhausted quota.","commonSituations":"Forgetting openai_api_key in the config when using the plain OpenAI provider; rotated/revoked keys; using Azure-style deployment names against api.openai.com; free-tier quota exhausted mid-run.","solutions":["Read e.__cause__ for the true OpenAI error before changing anything.","Ensure `openai_api_key` is set (env var OPENAI_API_KEY or explicit field) and is current.","Use a valid model id for api.openai.com, e.g. \"text-embedding-3-small\" or \"text-embedding-3-large\".","Handle 429s with exponential-backoff retry around the tool call."],"exampleFix":"# before\nconfig = AzureAISearchConfig(\n    ..., embedding_provider=\"openai\", embedding_model=\"text-embedding-3-small\",\n)  # openai_api_key missing -> 401 wrapped in ValueError\n\n# after\nconfig = AzureAISearchConfig(\n    ..., embedding_provider=\"openai\", embedding_model=\"text-embedding-3-small\",\n    openai_api_key=os.environ[\"OPENAI_API_KEY\"],\n)","handlingStrategy":"try-catch","validationCode":"def openai_embedding_config_ok(cfg) -> bool:\n    return bool(\n        str(cfg.embedding_provider or \"\").lower() == \"openai\"\n        and getattr(cfg, \"openai_api_key\", None)\n        and cfg.embedding_model\n    )","typeGuard":null,"tryCatchPattern":"try:\n    results = await tool.run(query)\nexcept ValueError as e:\n    if \"embeddings with OpenAI\" in str(e) and getattr(e.__cause__, \"status_code\", None) == 401:\n        raise RuntimeError(\"OpenAI API key missing or invalid\") from e\n    raise","preventionTips":["Always set openai_api_key (or ensure OPENAI_API_KEY env var) before use.","Retry 429s with exponential backoff; monitor quota dashboards."],"tags":["python","openai","embeddings","wrapper-exception"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}