Skip to content

Conversation

@cdbartholomew
Copy link
Contributor

@cdbartholomew cdbartholomew commented Jan 24, 2026

Summary

Fix api_key not being passed to Hindsight client in the litellm integration, and add sensible defaults for simpler API usage.

Changes

Bug fix:

  • Pass api_key to Hindsight client in recall(), reflect(), retain() functions
  • Add api_key parameter to wrap_openai() and wrap_anthropic() functions
  • Pass api_key when creating Hindsight client in wrapper classes

Sensible defaults for easier onboarding:

  • Default hindsight_api_url to https://api.hindsight.vectorize.io (production)
  • Default bank_id to "default"
  • Read api_key from HINDSIGHT_API_KEY environment variable if not provided

Simplified usage:

# Before (required explicit config)
client = wrap_openai(
    OpenAI(),
    bank_id="default",
    hindsight_api_url="https://api.hindsight.vectorize.io",
    api_key="your-key",
)

# After (just set HINDSIGHT_API_KEY env var)
client = wrap_openai(OpenAI())

Same simplification applies to wrap_anthropic() and configure().

Tests

  • Added 17 new unit tests for defaults behavior
  • Updated existing integration test for new default behavior
  • All 47 tests pass

@cdbartholomew cdbartholomew force-pushed the fix/litellm-api-key-auth branch from 2a008db to bdd2e9a Compare January 24, 2026 22:43
@cdbartholomew cdbartholomew marked this pull request as draft January 25, 2026 00:49
@cdbartholomew cdbartholomew marked this pull request as ready for review January 25, 2026 00:59
The recall(), reflect(), and retain() wrapper functions were creating
Hindsight client instances without passing the api_key from the config.
This caused 401 Unauthorized errors when using hindsight-litellm with
authenticated Hindsight API servers.

Also added api_key parameter to:
- HindsightOpenAI and HindsightAnthropic wrapper classes
- wrap_openai() and wrap_anthropic() functions
Make it easier to get started with hindsight-litellm by providing
sensible defaults:

- Default API URL: https://api.hindsight.vectorize.io (production)
- Default bank_id: "default"
- Read api_key from HINDSIGHT_API_KEY environment variable

Now users can simply do:

    client = wrap_openai(OpenAI())

With just the HINDSIGHT_API_KEY env var set, and it works.

Also adds comprehensive unit tests for the new defaults behavior.
@nicoloboschi nicoloboschi force-pushed the fix/litellm-api-key-auth branch from 49da265 to ef6db83 Compare January 26, 2026 09:11
nicoloboschi and others added 2 commits January 26, 2026 10:17
The test was calling configure(enabled=False) but configure() doesn't
have an enabled parameter. Changed to test is_configured() returns False
when reset_config() has been called.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…te_bank()

The parameter was named 'background' but the internal code used 'mission',
causing undefined variable errors. The tests also expected 'mission'.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@nicoloboschi nicoloboschi merged commit c0ca9b0 into main Jan 26, 2026
22 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants