openai-agents-python/tests/models
Ashok Saravanan 1994f9d4c4
feat: pass extra_body through to LiteLLM acompletion (#638)
**Purpose**  
Allow arbitrary `extra_body` parameters (e.g. `cached_content`) to be
forwarded into the LiteLLM call. Useful for context caching in Gemini
models
([docs](https://ai.google.dev/gemini-api/docs/caching?lang=python)).

**Example usage**  
```python
import os
from agents import Agent, ModelSettings
from agents.extensions.models.litellm_model import LitellmModel

cache_name = "cachedContents/34jopukfx5di"  # previously stored context

gemini_model = LitellmModel(
    model="gemini/gemini-1.5-flash-002",
    api_key=os.getenv("GOOGLE_API_KEY")
)

agent = Agent(
    name="Cached Gemini Agent",
    model=gemini_model,
    model_settings=ModelSettings(
        extra_body={"cached_content": cache_name}
    )
)
2025-05-14 12:34:27 -04:00
..
__init__.py Docs and tests for litellm (#561) 2025-04-21 16:59:01 -04:00
conftest.py Docs and tests for litellm (#561) 2025-04-21 16:59:01 -04:00
test_litellm_chatcompletions_stream.py Fix stream error using LiteLLM (#589) 2025-04-24 12:53:39 -04:00
test_litellm_extra_body.py feat: pass extra_body through to LiteLLM acompletion (#638) 2025-05-14 12:34:27 -04:00
test_map.py Docs and tests for litellm (#561) 2025-04-21 16:59:01 -04:00