Skip to content

[install-help]: keep getting error api key with openai #264

@lumintulogic-admin

Description

@lumintulogic-admin

Describe the issue
I installed context_chat_backend using app_api with custom environment variables set in deployment options. I filled in CC_EM_BASE_URL, CC_EM_APIKEY, and CC_EM_MODEL_NAME in the respective text input fields. I tried to connect to https://api.openai.com/v1/models with the provided api key using Postman, and it's successful. However, i keep getting an EmbeddingException error message saying that incorrect api key is provided.

Context Chat Backend logs

{
    "timestamp": "2026-01-21T11:36:29.543525+00:00",
    "level": "ERROR",
    "logger": "ccb.vectordb",
    "message": "Error adding documents to vectordb",
    "filename": "pgvector.py",
    "function": "add_indocuments",
    "line": 179,
    "thread_name": "AnyIO worker thread",
    "pid": 431,
    "version": "5.2.0",
    "exc_info": "Traceback (most recent call last):\n  File \"/app/context_chat_backend/vectordb/pgvector.py\", line 149, in add_indocuments\n    chunk_ids.extend(self.client.add_documents(indoc.documents[i:i+batch_size]))\n                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/usr/local/lib/python3.11/dist-packages/langchain_core/vectorstores/base.py\", line 279, in add_documents\n    return self.add_texts(texts, metadatas, **kwargs)\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/usr/local/lib/python3.11/dist-packages/langchain_postgres/vectorstores.py\", line 885, in add_texts\n    embeddings = self.embedding_function.embed_documents(texts_)\n                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/app/context_chat_backend/network_em.py\", line 134, in embed_documents\n    return self._get_embedding(texts)  # pyright: ignore[reportReturnType]\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/app/context_chat_backend/network_em.py\", line 92, in _get_embedding\n    raise e\n  File \"/app/context_chat_backend/network_em.py\", line 87, in _get_embedding\n    raise FatalEmbeddingException(response.text)\ncontext_chat_backend.types.FatalEmbeddingException: {\n    \"error\": {\n        \"message\": \"Incorrect API key provided: ***REDAC**D***. You can find your API key at https://platform.openai.com/account/api-keys.\",\n        \"type\": \"invalid_request_error\",\n        \"param\": null,\n        \"code\": \"invalid_api_key\"\n    }\n}\n",
    "source_id": "files__default: 30482854"
}

Setup Details (please complete the following information):

  • Nextcloud Version: 32.0.5
  • AppAPI Version: 32.0.0
  • Context Chat PHP Version 5.2.0
  • Context Chat Backend Version 5.2.0
  • Nextcloud deployment method: nginx bare-metal
  • Context Chat Backend deployment method: app_api daemon harp_proxy_docker

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions