Skip to content

Conversation

@AshokSaravanan222
Copy link
Contributor

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).

Example usage

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} ) )
@github-actions
Copy link
Contributor

This PR is stale because it has been open for 10 days with no activity.

@github-actions github-actions bot added the stale label May 12, 2025
@rm-openai rm-openai merged commit 1994f9d into openai:main May 14, 2025
5 checks passed
KatHaruto pushed a commit to KatHaruto/openai-agents-python that referenced this pull request Jun 10, 2025
**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} ) )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2 participants