Skip to content

[HIGH] Replace hardcoded Ollama API keys with proper configuration #499

@joelfuller2016

Description

@joelfuller2016

Summary

Severity: 🟠 HIGH
Files: 3 locations in Ollama integration
Category: Hardcoded Values - Configuration Management

Problem

Multiple Ollama providers use hardcoded dummy API key "ollama" instead of proper configuration handling.

Affected Files

1. LLM Provider

File: apps/backend/integrations/graphiti/providers_pkg/llm_providers/ollama_llm.py:49

llm_config = LLMConfig(
    api_key="ollama",  # Ollama requires a dummy API key
    model=config.ollama_llm_model,
    # ...
)

2. Embedder Provider

File: apps/backend/integrations/graphiti/providers_pkg/embedder_providers/ollama_embedder.py:121

api_key="ollama",  # Ollama requires a dummy API key

3. Cross-Encoder

File: apps/backend/integrations/graphiti/providers_pkg/cross_encoder.py:57

api_key="ollama",

Impact

  • ❌ If actual API validation is enforced, authentication will fail
  • ❌ Cannot customize API key via configuration
  • ❌ Hardcoded values prevent environment-specific overrides
  • ❌ Violates configuration management best practices

Proposed Solution

Option 1: Environment Variable (Recommended)

# In each provider
api_key = os.environ.get("OLLAMA_API_KEY", "ollama")  # Default to "ollama" if not set

Option 2: Configuration File

# In config
ollama_api_key: str = "ollama"  # Can be overridden in config

# In provider
api_key=config.ollama_api_key

Option 3: Conditional Based on Endpoint

# Only use dummy key for local Ollama
api_key = "ollama" if base_url.startswith("http://localhost") else config.ollama_api_key

Acceptance Criteria

  • All 3 hardcoded "ollama" strings replaced with configuration
  • Support environment variable override
  • Default to "ollama" for backward compatibility
  • Document Ollama API key requirements
  • Test with real Ollama installation

Priority

HIGH - Should be fixed in next sprint

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions