-
Notifications
You must be signed in to change notification settings - Fork 399
OpenAI provider sends max_completion_tokens — breaks Mistral (and likely other) OpenAI-compatible endpoints #852
Copy link
Copy link
Open
Description
Problem
When using HINDSIGHT_API_LLM_PROVIDER=openai with HINDSIGHT_API_LLM_BASE_URL pointed at Mistral's API (https://api.mistral.ai/v1), Hindsight crashes on startup during verify_connection.
The OpenAI-compatible provider sends max_completion_tokens in the chat completion request, but Mistral's API only accepts max_tokens and rejects the request with a 422:
openai.UnprocessableEntityError: Error code: 422 - {
'object': 'error',
'message': {'detail': [{'type': 'extra_forbidden', 'loc': ['body', 'max_completion_tokens'],
'msg': 'Extra inputs are not permitted', 'input': 100}]},
'type': 'invalid_request_error'
}
RuntimeError: Connection verification failed for openai/mistral-small-latest
This is a known incompatibility — Mistral (and several other providers) haven't adopted max_completion_tokens and expect max_tokens instead. See mistralai/platform-docs-public#7.
Expected behavior
The openai provider with a custom BASE_URL should work with any OpenAI-compatible API, including Mistral. Either:
- Use
max_tokensinstead ofmax_completion_tokenswhen a custom base URL is set, or - Add
mistralas a first-class provider (with correct parameter mapping), or - Catch the 422 and fall back to
max_tokens
Workaround
Using litellm as the provider works, since LiteLLM handles the parameter translation:
HINDSIGHT_API_LLM_PROVIDER=litellm
HINDSIGHT_API_LLM_MODEL=mistral/mistral-small-latest
HINDSIGHT_API_LLM_API_KEY=<key>
MISTRAL_API_KEY=<key>
Environment
- Hindsight v0.4.22 (Docker,
ghcr.io/vectorize-io/hindsight:latest) - Mistral model:
mistral-small-latest - Base URL:
https://api.mistral.ai/v1
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels