Problem
The inline completions (autocomplete) in the LiteLLM provider fail when using chat-only models like Anthropic Claude because the code only uses the prompt/suffix parameters (fill-in-the-middle format):
litellm_resp = litellm.completion(
model=model_id,
prompt=prefix,
suffix=suffix,
...
)
This results in errors: litellm.BadRequestError: Anthropic requires at least one non-system message.
Root Cause
- Some models (OpenAI Codex, etc.) support FIM with prompt/suffix parameters
- Chat-only models (Anthropic, most modern LLMs) only support messages format
- The current implementation only tries FIM format
Proposed Solution
Implement a fallback mechanism:
- Try FIM format first (prompt/suffix) for models that support it
- If that fails, fall back to messages format with proper prompt construction
- Strip markdown code blocks from responses (chat models often return formatted code)
This maintains backward compatibility with FIM-capable models while adding support for chat-only models.
Impact
Users can now use Anthropic Claude and other chat-only models for inline completions through the LiteLLM provider.
Problem
The inline completions (autocomplete) in the LiteLLM provider fail when using chat-only models like Anthropic Claude because the code only uses the
prompt/suffixparameters (fill-in-the-middle format):This results in errors:
litellm.BadRequestError: Anthropic requires at least one non-system message.Root Cause
Proposed Solution
Implement a fallback mechanism:
This maintains backward compatibility with FIM-capable models while adding support for chat-only models.
Impact
Users can now use Anthropic Claude and other chat-only models for inline completions through the LiteLLM provider.