Skip to content

Gemini Developer API Integration to smolagents #1227

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

rahim-xelpmoc
Copy link

Gemini Developer API Usage Examples

This pull request updates the documentation for the Gemini Developer API, refining sample usage instructions for better readability and precision.
Prerequisite
To use the Gemini Developer API, export your API key as an environment variable:

export GOOGLE_API_KEY=<your_api_key>

Sample Usage

1. ToolCallingAgent

from smolagents import DuckDuckGoSearchTool, GeminiModel, ToolCallingAgent

# Initialize Gemini tool model
gemini_tool_model = GeminiModel(model_id="gemini-2.0-flash")

# Configure ToolCallingAgent with Gemini and DuckDuckGo
agent = ToolCallingAgent(
    model=gemini_tool_model,
    tools=[
        DuckDuckGoSearchTool(),
    ],
)

# Execute a query
agent.run("What is the price of the latest iPhone in India?")

2. CodeAgent

from smolagents import DuckDuckGoSearchTool, GeminiModel, CodeAgent

# Initialize Gemini model for CodeAgent
gemini_model = GeminiModel(is_code_agent=True)

# Configure CodeAgent with Gemini and DuckDuckGo
agent = CodeAgent(
    model=gemini_model,
    tools=[
        DuckDuckGoSearchTool(),
    ],
)

# Execute a query
agent.run("What is the price of the latest iPhone in India?")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant