Tool Use

Give a GPT-5.6 Luna agent web search tools through a LiteLLM proxy.

OPENAI_API_KEY belongs to the upstream OpenAI account. LITELLM_API_KEY is the agent client's proxy bearer value: local-proxy is a placeholder for this local server, which has no authentication configured by these commands. If you configure proxy authentication, supply its accepted key instead. Exporting a client key alone does not configure server authentication.

tool_use.py
"""Run `uv pip install ddgs` to install dependencies."""

from agno.agent import Agent
from agno.models.litellm import LiteLLMOpenAI
from agno.tools.websearch import WebSearchTools

# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------

agent = Agent(
    model=LiteLLMOpenAI(id="gpt-5.6-luna"),
    tools=[WebSearchTools()],
    markdown=True,
)
agent.print_response("Whats happening in France?")

# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------

if __name__ == "__main__":
    pass

Run the Example

Set up your virtual environment

uv venv --python 3.12
source .venv/bin/activate

Install dependencies

uv pip install -U agno "litellm[proxy]" ddgs openai

Export your API keys

export LITELLM_API_KEY="local-proxy"
export OPENAI_API_KEY="your_openai_api_key_here"

Start LiteLLM

In the first terminal, with OPENAI_API_KEY set, start the proxy below and leave it running:

litellm --model gpt-5.6-luna --host 127.0.0.1 --port 4000

Point the client at the local proxy

Add base_url="http://127.0.0.1:4000" to LiteLLMOpenAI(...) in the saved file. In a second terminal, activate the same virtual environment and set LITELLM_API_KEY as above before running the agent. The foreground proxy uses the model selected by its CLI command.

Run the example

Save the code above as tool_use.py, then run:

python tool_use.py

Full source: cookbook/90_models/litellm_openai/tool_use.py