BerriAI/litellm · error · ValueError

No matching adapter given. Received 'adapter_id'={adapter_id

Error message

No matching adapter given. Received 'adapter_id'={adapter_id}, litellm.adapters={litellm.adapters}

What it means

aadapter_completion() routes by adapter_id through litellm.adapters, a list of {'id', 'adapter'} registrations. When no entry's id equals the given adapter_id, a ValueError is raised echoing the id you passed and the currently registered adapters.

Source

Thrown at litellm/main.py:7389

    return text_completion_response


###### Adapter Completion ################


async def aadapter_completion(*, adapter_id: str, **kwargs) -> BaseModel | AdapterCompletionStreamWrapper | None:
    """
    Implemented to handle async calls for adapter_completion()
    """
    try:
        translation_obj: CustomLogger | None = None
        for item in litellm.adapters:
            if item["id"] == adapter_id:
                translation_obj = item["adapter"]

        if translation_obj is None:
            raise ValueError(
                f"No matching adapter given. Received 'adapter_id'={adapter_id}, litellm.adapters={litellm.adapters}"
            )

        new_kwargs: Final = translation_obj.translate_completion_input_params(kwargs=kwargs)

        response: Final[ModelResponse | CustomStreamWrapper] = await acompletion(**new_kwargs)
        translated_response: BaseModel | AdapterCompletionStreamWrapper | None = None
        if isinstance(response, ModelResponse):
            translated_response = translation_obj.translate_completion_output_params(response=response)
        if isinstance(response, CustomStreamWrapper):
            translated_response = translation_obj.translate_completion_output_params_streaming(
                completion_stream=response
            )

        return translated_response
    except Exception as e:
        raise e

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Register before calling: litellm.adapters.append({'id': 'my_adapter', 'adapter': MyAdapter()})
  2. For Gemini-style requests use the bundled id exactly: adapter_id='gemini'
  3. Match the id string exactly — look it up in litellm.adapters
  4. Centralize adapter registration at application startup

Example fix

# before
resp = await litellm.aadapter_completion(adapter_id="gemini", **kwargs)

# after
from litellm.adapters.gemini import GeminiRender
litellm.adapters.append({"id": "gemini", "adapter": GeminiRender()})
resp = await litellm.aadapter_completion(adapter_id="gemini", **kwargs)
Defensive patterns

Strategy: validation

Validate before calling

import litellm

def get_adapter(adapter_id: str):
    for item in litellm.adapters:
        if item["id"] == adapter_id:
            return item["adapter"]
    raise KeyError(f"adapter {adapter_id!r} not registered; known: {[a['id'] for a in litellm.adapters]}")

Try / catch

try:
    resp = await litellm.aadapter_completion(adapter_id=aid, **kwargs)
except ValueError as e:
    if "No matching adapter" in str(e):
        raise RuntimeError(f"adapter {aid!r} not registered") from e
    raise

Prevention

When it happens

Trigger: await litellm.aadapter_completion(adapter_id='my_adapter', **kwargs) before appending {'id': 'my_adapter', 'adapter': MyAdapter()} to litellm.adapters; or an id typo such as 'Gemini' vs 'gemini' (matching is exact).

Common situations: Using the documented Gemini adapter without registering it first (litellm.adapters.append({'id': 'gemini', 'adapter': GeminiRender()})); registration code that runs after the call or in a different worker process.

Related errors


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/61a33ed734cf2130. Report an issue: GitHub.